• Post Reply Bookmark Topic Watch Topic
  • New Topic

Snippet  RSS feed

 
Meenaakshi Bala Shanmugam
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class check {
public static void main(String[] args) {
System.out.println(0x10 + 10 + 010);
}}

when the program runs it produces 34 as output.

can somebody tel the reason
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

This is the Ranch Office forum -- which is used to post questions regarding the javaranch site itself. Let me move this topic to the beginners java forum for you.

Henry
 
Henry Wong
author
Sheriff
Posts: 23295
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Meenaakshi Bala Shanmugam wrote:public class check {
public static void main(String[] args) {
System.out.println(0x10 + 10 + 010);
}}

when the program runs it produces 34 as output.

can somebody tel the reason


Do you know the difference between octal, decimal, and hexadecimal numbers? Basically... 16 + 10 + 8 => 34.

Henry
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!