• Post Reply Bookmark Topic Watch Topic
  • New Topic

Doubt on char  RSS feed

 
Nikhil Bansal
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Look at the foll. code

class MCZ24 {
public static void main (String[] args) {
char a = 061; // 1
char b = '\61'; // 2
char c = '\061'; // 3
char d = 0x0031; // 4
char e = '\u0031'; // 5
System.out.print(""+a+b+c+d+e);
}}

Howcome statements 2 and 3 are valid?

Regards

Nikhil Bansal
 
Barry Gaunt
Ranch Hand
Posts: 7729
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Take a look at section 3.10.6 in the current Java Language Specification, especially the bit on octal escape sequences.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!