aspose file tools*
The moose likes Beginning Java and the fly likes Number format exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Number format exception " Watch "Number format exception " New topic
Author

Number format exception

vignesh Thamarai
Ranch Hand

Joined: Mar 10, 2009
Posts: 31
hello friends,
i have a hashset contain integers like 1,2,4,5 . now i want to get every integer value from hashset.

here is my code. set2 is a hashset.




it throws a number format exception , i try this one this too not helping me


please help me what iam missing...
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40034
    
  28
What have you put into the Set in the first place? If there are Integers in it, there is no need to mess around with the parseInt and toString methods; you simply get the Integer out and can convert it to an int with auto-unboxing if necessary.

Your code is poorly formatted, which makes it difficult to read; there should, for example, be a single space after the semicolons in the for () line. Put the line starting int i = inside a try block, then follow it with a catch, so ti reads like thisThat will allow you to see what you have in your Set that isn't a number.

And why don't you parameterise the set as a Set<Integer>?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Number format exception