?
Solved

Exception in thread main

Posted on 2005-04-04
7
Medium Priority
?
236 Views
Last Modified: 2010-03-31
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
Comment
Question by:sharath123in
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 92

Accepted Solution

by:
objects earned 375 total points
ID: 13703355

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
 

Author Comment

by:sharath123in
ID: 13703365
It say's exception in thread main..when I am trying to execute
0
 
LVL 92

Expert Comment

by:objects
ID: 13703370
or as a List use:

L.add(Arrays.asList(new String[] { "4", "5.5" }));
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 92

Expert Comment

by:objects
ID: 13703377
code looks fine, how are you running it?

Should be

java Linkedlist
0
 
LVL 8

Expert Comment

by:koppcha
ID: 13703403
No Problem with code

javac Linkedlist.java
javac Linkedlist
should return the output
 Link list :[23, 45, 12, 15, 10]
0
 

Author Comment

by:sharath123in
ID: 13703406
I am using text pad ..so I am using ctrl+2 to run it
0
 
LVL 92

Expert Comment

by:objects
ID: 13703415
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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Suggested Courses
Course of the Month11 days, 9 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question