Q. In java langauge (Netbeans) // please with comments ,thanks a lot Your are gi
ID: 3770094 • Letter: Q
Question
Q. In java langauge (Netbeans)
// please with comments ,thanks a lot
Your are given a Node class and a List class : Write a code that takes the array and the list as arguments, and fills the first five nodes in the list with the first positive numbers in the array using a proper loop. Draw the List after applying the code. Draw the Final shape of the List after applying the code and the following statements as well: Node p=first.next.next.next; p.next.next.data= myArray[11]; p.next.next.next=first;Explanation / Answer
public class Node{
int data;
Node next;
}
public class List{
Node first;
}
public class Test{
public static InitializeList(int a[],List l1){
List temp = l1;
for(int i = 0; i < 5; i++){
temp.data = a[i];
temp = temp.next;
}
}
public static DrawList(List l1){
List temp = l1;
while(temp != null){
System.out.print(temp.data + "->");
temp = temp.next;
}
}
public static void main(String args[]){
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.