Casting in Java | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Casting in Java

Can someone tell me what I've done wrong here? I have to output the int value of a char using cast. import java.util.Scanner; class Main { public static void main(String[] args) { Scanner read = new Scanner(System.in); char a = read.next().charAt(0); //your code goes here int b =(int)a; System.out.println(b); }

20th Mar 2021, 2:28 PM
Zotta
Zotta - avatar
1 Answer
+ 3
Missing a '}' after System.out.println(b);
20th Mar 2021, 3:50 PM
你知道規則,我也是
你知道規則,我也是 - avatar