• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Getting number format exception when trying to use parseInt

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem occurs at the second to last line of text in this code. This is a homework assignment so can someone give me a hint as to what I'm doing wrong?


 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to JavaRanch. What do you reckon the toString method returns for an array? What does it actually return?
 
Greenhorn
Posts: 15
Mac Netbeans IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It would be very useful if you could provide the exact error message.
 
bob joe
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Amir Al. wrote:It would be very useful if you could provide the exact error message.


Exception in thread "main" java.lang.NumberFormatException: For input string: "[C@29428e"

 
Sheriff
Posts: 67747
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bob joe wrote:

Amir Al. wrote:It would be very useful if you could provide the exact error message.


Exception in thread "main" java.lang.NumberFormatException: For input string: "[C@29428e"


As "[C@29428e" certainly isn't a valid number, the error is not surprising. You need to answer Ulf's question.
 
bob joe
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the hints. It works now. I did away with using toString. Honestly still not sure why it was returning garbage though, but I guess I'll look into it later.

 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

bob joe wrote:Thanks for the hints. It works now. I did away with using toString. Honestly still not sure why it was returning garbage though, but I guess I'll look into it later.


I suggest you do, because it's quite important.

Hint: where does toString() originate?

Winston
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

I did away with using toString. Honestly still not sure why it was returning garbage though


Definitely not garbage, just something other than what you assumed it would return.
 
reply
    Bookmark Topic Watch Topic
  • New Topic