CSC113_Tutorial12 - new LinkedList<Integer>...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
King Saud University College of Computer and Information Systems, Department of Computer Science CSC 113: Java Programming-II, Spring2011, 22 April, 2011 Tutorial #12 : Linked List Write a Linked list program in Java by creating two list one for studentid and other for studentname. The studentid and studentname is declared as array. Declare the size of Array and give the values of studentno and studentname. Declare two Linkedlist one for Studentno and another for studentname. Use the addfirst and addlast method to insert in front and at the end. Now try to show the size of the array and the value inserted. HINT: Creating Linkedlist For Studentno and studentname LinkedList <Integer>Studentno =
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: new LinkedList<Integer>(); LinkedList <String>studentname = new LinkedList<String>(); Add the List: Studentno.add(studentno1[i]);//adding value thru array Studentname.add(studentname[i]);adding name thru array Add First and Last in studentno & name Studentno.addFirst() // To add in front Studentno.addLast()//To add in last ______________________________________________________________________________ Output: Student id: 1 2 3 4 5 Student name: A B C D E Linked list size: 5 Adding data at 1st location: Student id: 0 1 2 3 4 5 Student name: F A B C D E Linked list size: 6 Adding data at last location: Student id: 0 1 2 3 4 5 6 Student name: F A B C D E G Linked list size: 7...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online