• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 245
  • Last Modified:

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);
      }
}
0
sharath123in
Asked:
sharath123in
  • 4
  • 2
1 Solution
 
objectsCommented:

Whats the error with it?

to add three strings to a node, use a list or an array

L.add(new String[] { "4", "5.5" });

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

L.add(Arrays.asList(new String[] { "4", "5.5" }));
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
objectsCommented:
code looks fine, how are you running it?

Should be

java Linkedlist
0
 
koppchaCommented:
No Problem with code

javac Linkedlist.java
javac Linkedlist
should return the output
 Link list :[23, 45, 12, 15, 10]
0
 
sharath123inAuthor Commented:
I am using text pad ..so I am using ctrl+2 to run it
0
 
objectsCommented:
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.
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now