Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

LinkedList<Integer>[] (Generic Java)

807598Sep 9 2006 — edited Sep 9 2006
Hi guys,

I read that we need to do this
LinkedList<Integer> test = new LinkedList<Integer>();
in order to have to specify the object type. What if the linked list is an array?

My init code is something like this
	LinkedList[] list;
	int size, max_length, total_elements;
    // Constructor
	public SortedList(int n) {
		// Set Total Elements
		total_elements = 0;
		// Deteermine The Size Of The Linked List Array
		size = (int) Math.sqrt(n);
		// Determine The Max Length Of Individual Linked List
		max_length = (int) n/size;
		// Create The Linked List
		list = new LinkedList[size];
		// Init The Linked List
		for(int i = 0; i < size; i++) {
			list[i] = new LinkedList();
		}
	}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 7 2006
Added on Sep 9 2006
8 comments
705 views