This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes String.format problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "String.format problem" Watch "String.format problem" New topic
Author

String.format problem

Surasak Leenapongpanit
Ranch Hand

Joined: May 10, 2002
Posts: 341
Hi, all

Why the below throws java.lang.ArrayIndexOutOfBoundsException.



when I change the value from 9.81 to 12.81, it run without exception.

Thank you,
Surasak Leenapongpanit
raj malhotra
Ranch Hand

Joined: Feb 22, 2007
Posts: 286
for 9.81 ,i am not getting any exception .It will print 10.
Shaan Shar
Ranch Hand

Joined: Dec 27, 2005
Posts: 1249

Originally posted by Surasak Leenapongpanit:
Hi, all

Why the below throws java.lang.ArrayIndexOutOfBoundsException.



when I change the value from 9.81 to 12.81, it run without exception.

Thank you,
Surasak Leenapongpanit



When I tried, It's giving perfect solution i.e 13.

Just check the whole code once again or you can paste the code over here. SO that we can look into this issue.


The Best way to predict your future is to create it - Every great individual common man
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: String.format problem
 
It's not a secret anymore!