• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Please help

 
Sherry Jacob
Ranch Hand
Posts: 128
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can any1 explain how and why...

 
Stuart Gray
Ranch Hand
Posts: 410
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Those results are correct. If you read the API docs for the relevant classes (Byte, Short, etc) at ( java.sun.com/j2se/1.5.0/docs/api/ ), you will see the second argument specifies the base of the first argument. So in the second example you are saying "what is the octal value 012 in decimal?". And you get the correct answer is:

(1*8) +
(2*1)
= 10
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic