File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

LinkedList Problem

 
Steven Alvarez
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Steven Alvarez
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anyone?
 
Steven Alvarez
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I change this line so I don't need the mynumber class?

 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Subclass your MyNumber and override the toString() method is one way to do it.
 
Steven Alvarez
Ranch Hand
Posts: 66
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you show me how to do that?
 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic