Link to home
Start Free TrialLog in
Avatar of komlaaa
komlaaa

asked on

LinkedList with Template

Hi,
I am testing template on JDK1.5 but i am getting NullPointerException at line pointed below. What am i doing wrong?

====================
import java.util.LinkedList;

public class TestALinkedList {
      /**
       * @param args
       */
      public static void main(String[] args) {
            // TODO Auto-generated method stub
             LinkedList [] list = new LinkedList[3];
                                
               list[1].add( new Integer(1) ); <============ NullPointerException.

      }

}
Avatar of Mick Barry
Mick Barry
Flag of Australia image

you dont add ant elements to your arry
so list[1] is null
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of komlaaa
komlaaa

ASKER

true, i should have known that