- Edit the
file List.java
and write the
void put(x, k) method
that inserts a node containing the value
x at the
position k
of the list
- Test program file used in part 1:
- Compile and run:
javac testProg1.java
java testProg1
|
Correct result is:
Testing the put() method
Insert 1 is correct !
myList = [7.0]
Insert 2 is correct !
myList = [6.0 , 7.0]
Insert 3 is correct !
myList = [1.0 , 6.0 , 7.0]
Insert 4 is correct !
myList = [1.0 , 2.0 , 6.0 , 7.0]
Insert 5 is correct !
myList = [1.0 , 2.0 , 3.0 , 6.0 , 7.0]
Insert 6 is correct !
myList = [1.0 , 2.0 , 3.0 , 4.0 , 6.0 , 7.0]
Insert 7 is correct !
myList = [1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0]
Insert 8 is correct !
myList = [1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0]
Insert 9 is correct !
myList = [1.0 , 2.0 , 3.0 , 4.0 , 5.0 , 6.0 , 7.0 , 8.0 , 9.0]
|
|