Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

char problem

 
Kunal Choudhary
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
public class testoperator
{

public static void main(String args[])
{

char x='51';

System.out.println(x);

}


}
why error???
 
Vikas Kapoor
Ranch Hand
Posts: 1374
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Kunal,

I think you are trying to achieve ,
char x=51; // This is equivalent to 3 (ASCII)

'51' can't fit into single character.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic