Can anyone please tell me why i am getting an error in the following code?
]
Code:
class Char_Demo
{
public static void main(String[] n)
{
// we all know we can store a character literal like A or //B in an char variable
char c='A';
System.out.println("Character c has" +c); //output is A
// we can even store the ASCII value for A
char c1=65;
System.out.println("Character c1 has" +c1 );//output is A
//But now i want to store a number as a character
char c2='5'; // 5 stored as a character System.out.println("Character c2 has" +c2 );//output is 5
// but when i store a number which has more then 1 digit //i get an compile-time error
char c3='12'; // error....why this error comes
System.out.println("Character c3 has" +c3 );
}
}
Comment