Keyboard input int type, enter A but reported an error, solve!

import java.util.Scanner;

public class Testtttt {

public static void main(String args[]){

Scanner sc=new Scanner (System.in);

System.out.println(":");
int n=sc.nextInt();
char word=(char) n;
System.out.println(n);
System.out.println(word);
}

}-sharp-sharp-sharp topic description

sources of topics and their own ideas

related codes

/ / Please paste the code text below (do not replace the code with pictures)

what result do you expect? What is the error message actually seen?

Jun.18,2021

Why did you lose A when you were asked to enter int,? of course you reported it wrong

the purpose of this program is to teach you: if the int type variable converts the char type strongly, you will get the characters corresponding to the ASCII table

. The

nextInt method can only accept int parameters. The program is divided into two parts. The first part is to accept int values from the keyboard, and the second part is to convert int to ASCII corresponding characters

.
Menu