Link to home
Start Free TrialLog in
Avatar of sharath123in
sharath123in

asked on

Exception in thread main

Here is my module to create a linked list and display it..How can I fix the error with it..and I want to add3 data element in one node ..How can I do that..
L.add("4","5.5");
..............

import java.util.*;
class Linkedlist
{
public static void main(String args[])
{
      LinkedList L = new LinkedList();
      L.add("23");
      L.add("45");
      L.add("12");
      L.add("15");
      L.add("10");
      System.out.println("  Link list :"+ L);
      }
}
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 sharath123in
sharath123in

ASKER

It say's exception in thread main..when I am trying to execute
or as a List use:

L.add(Arrays.asList(new String[] { "4", "5.5" }));
code looks fine, how are you running it?

Should be

java Linkedlist
No Problem with code

javac Linkedlist.java
javac Linkedlist
should return the output
 Link list :[23, 45, 12, 15, 10]
I am using text pad ..so I am using ctrl+2 to run it
is that the complete error you are getting?  or does it include more information.

Make sure your classpath contains the directory that your class file is in.