java编译运行出现这个怎么解决java.util.Scanner[delimiters=\p{javaWhitespace}+][position=4][match va
importjava.util.Scanner;publicclassQQ{publicstaticvoidmain(String[]args){Scanners1=ne...
import java.util.Scanner;
public class QQ {
public static void main (String[] args){
Scanner s1 = new Scanner(System.in);
System.out.println("输入你的姓名");
s1.nextLine();
Scanner s2 = new Scanner(System.in);
System.out.println("输入你的年龄");
s2.nextLine();
Scanner s3 = new Scanner(System.in);
System.out.println("输入你的薪资");
s3.nextLine();
System.out.println(s1+" "+s2+" "+s3+" ");
}
} 展开
public class QQ {
public static void main (String[] args){
Scanner s1 = new Scanner(System.in);
System.out.println("输入你的姓名");
s1.nextLine();
Scanner s2 = new Scanner(System.in);
System.out.println("输入你的年龄");
s2.nextLine();
Scanner s3 = new Scanner(System.in);
System.out.println("输入你的薪资");
s3.nextLine();
System.out.println(s1+" "+s2+" "+s3+" ");
}
} 展开
1个回答
展开全部
你好歹定义一个String str=s1.nextLine();这样啊,你这是直接打印对象啊,没有你这种写法
追问
能帮忙改好贴出可运行的代码不,java真的不太会
追答
mport java.util.Scanner;
public class QQ {
public static void main (String[] args){
Scanner s1 = new Scanner(System.in);
System.out.println("输入你的姓名");
String name=s1.nextLine();
Scanner s2 = new Scanner(System.in);
System.out.println("输入你的年龄");
String age=s2.nextLine();
Scanner s3 = new Scanner(System.in);
System.out.println("输入你的薪资");
String salary=s3.nextLine();
System.out.println(name+" "+age+" "+salary+" ");
}
}
简单改了下,正常只用一个scanner,输入完还要记得关闭.close()
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询