//Two slashes on one line
/*If there are multiple lines
With slash
Surround with an asterisk
*/
//Assign the entered string to the variable words
String words = new java.util.Scanner(System.in).nextLine();
//Assign the entered integer to the variable value
int value = new java.util.Scanner(System.in).nextInt();
System.out.println("Character string to display");
System.out.print("Character string to display");
int n = Integer.parseInt(stringNumber);
Example: Convert 1 and 2 of character string to integer and add
String s_1 = "1";
String s_2 = "2";
//Add as a string->12 is output
System.out.println(s_1 + s_2);
//Convert to integer
int i_1 = Integer.parseInt(s_1);
int i_2 = Integer.parseInt(s_2);
//Convert to an integer and then add->3 is output
System.out.println(i_1 + i_2);
<Execution result>
12
3
Recommended Posts