我一直试图将字符转换为ASCII。请帮忙,这是我的代码。
import java.util.*;
public class CharToAscii {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("ENter the character you want to convert");
char c = sc.next().charAt(0);
System.out.println(int(c));
}
}
答案 0 :(得分:0)
System.out.println(int(c));
行给出错误
TypeCasting应该通过将类型放在圆括号中来完成。
System.out.println((int)(c));
是CORRECT实施。