3:53 pm - Tuesday March 25, 3360

LinkedList Example Program for toArray()

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044
/**
*LinkedList Example Program for toArray()
* @author   candidjava.com
* @description:  Returns an array containing all of the elements in this list in proper sequence (from first to last element).
*/
import java.util.*;
public class List12 {
public static void main(String[] args) {
LinkedList a = new LinkedList();// create object for linkedlist.
a.add("g");
a.add("f");
a.add("s");// add elements in list
a.add("d");
a.add("c");
Object[] s = a.toArray();// this method display the array objects:
for (int i = 0; i < s.length; i++) {
System.out.println(s[i]);
}
}
}


Output:

g
f
s
d
c

BACK

Filed in: Z-A All Java Codes

Comments are closed.