This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Output of the program

 
vijaya tr
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
class Q19 {

public static void main(String[] args) {
int i=2 + '2';
System.out.println(i);
}
}
When I compile and execute this program the output is 52. Can somebody explain
 
sachin patel
Ranch Hand
Posts: 75
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what i think'
ASCII value or better Unicode value of '2' is 50 and that is added to 2 which makes it 52....
Hope this helps
------------------
Sachin,
****************************************************
Learn from others mistakes. Life is too short to make all yourself.
****************************************************
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic