GeeCON Prague 2014*
The moose likes Java in General and the fly likes LinkedList Problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Java in General
Bookmark "LinkedList Problem" Watch "LinkedList Problem" New topic
Author

LinkedList Problem

Steven Alvarez
Ranch Hand

Joined: Nov 01, 2006
Posts: 66
I have the following code:


What I need help with is the "deleteOdd" function. It's suppose to take a linkedlist with 10 positions, holding the numvbers 0 - 9, and take the odd numbers out. Whats wrong with my function? I get this error:



Can someone help me?
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

From the stacktrace, it seems that these lines are the main culprit.

The value that was passed to Integer.parseInt() was "My number is 0", which can't be parsed to int. But I'm not sure how you inserted that String into your list.


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Steven Alvarez
Ranch Hand

Joined: Nov 01, 2006
Posts: 66
My professor messed up this code. How can I change this class so when I call the ToString it simply converts the object into a string?

Steven Alvarez
Ranch Hand

Joined: Nov 01, 2006
Posts: 66
anyone?
Steven Alvarez
Ranch Hand

Joined: Nov 01, 2006
Posts: 66
How can I change this line so I don't need the mynumber class?

Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959

Subclass your MyNumber and override the toString() method is one way to do it.
Steven Alvarez
Ranch Hand

Joined: Nov 01, 2006
Posts: 66
Can you show me how to do that?
Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959


Insert the class of MyAnotherNumber instead of MyNumber into the list.
I leave it to you as a homework since it looks like a homework question
[ March 08, 2008: Message edited by: Freddy Wong ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: LinkedList Problem