我可以在java中获取和打印整数值,但我很困惑如何获取和打印字符串。有人可以帮忙吗package hello;import java.util.Scanner;public class hello { public static void main(String[] args) { int integer; System.out.println("Please Enter Integer"); Scanner sc = new Scanner(System.in); integer = sc.nextInt(); sc.close(); System.out.println("you entered : " +integer); }}程序输出Please Enter Integer5you entered : 5我被困在这个程序中。我不明白如何获取字符串并在屏幕上打印import java.util.Scanner;public class hello { public static void main(String[] args) { int name; Scanner sc = new Scanner(System.in); System.out.println("Enter your name"); name = sc.nextInt(); sc.close(); System.out.println("Your name"+name); }}
添加回答
举报
0/150
提交
取消