为什么我用nextInt会报错
packagejava.uyil;//importjava.util.Scanner;importjava.util.*;//importjava.publicclass...
package java.uyil;
//import java.util.Scanner;
import java.util.*;
//import java.
public class Scanner {
public static void main(String[]args){
Scanner scanner= new Scanner();
System.out.print("请输入学生年龄:");
int ageOfStudent = scanner.nextInt();
System.out.println("该生是否满18岁?"+
(ageOfStudent>=18?"yes":"no"));
}
}
package java.uyil;
//import java.util.Scanner;
import java.util.*;
//import java.
public class Test {
public static void main(String[]args){
Scanner scanner= new Scanner(System.in);
System.out.print("请输入学生年龄:");
int ageOfStudent = scanner.nextInt();
System.out.println("该生是否满18岁?"+
(ageOfStudent>=18?"yes":"no"));
}
} 展开
//import java.util.Scanner;
import java.util.*;
//import java.
public class Scanner {
public static void main(String[]args){
Scanner scanner= new Scanner();
System.out.print("请输入学生年龄:");
int ageOfStudent = scanner.nextInt();
System.out.println("该生是否满18岁?"+
(ageOfStudent>=18?"yes":"no"));
}
}
package java.uyil;
//import java.util.Scanner;
import java.util.*;
//import java.
public class Test {
public static void main(String[]args){
Scanner scanner= new Scanner(System.in);
System.out.print("请输入学生年龄:");
int ageOfStudent = scanner.nextInt();
System.out.println("该生是否满18岁?"+
(ageOfStudent>=18?"yes":"no"));
}
} 展开
展开全部
需要修改package 里面的java, 关键字不能用在包名
Scanner scanner= new Scanner(System.in);你要输入整数才可以
package java1.a;
//import java.util.Scanner;
import java.util.*;
//import java.
public class Test {
public static void main(String[]args){
Scanner scanner= new Scanner(System.in);
System.out.print("请输入学生年龄:");
int ageOfStudent = scanner.nextInt();
System.out.println("该生是否满18岁?"+
(ageOfStudent>=18?"yes":"no"));
}
}
Scanner scanner= new Scanner(System.in);你要输入整数才可以
package java1.a;
//import java.util.Scanner;
import java.util.*;
//import java.
public class Test {
public static void main(String[]args){
Scanner scanner= new Scanner(System.in);
System.out.print("请输入学生年龄:");
int ageOfStudent = scanner.nextInt();
System.out.println("该生是否满18岁?"+
(ageOfStudent>=18?"yes":"no"));
}
}
追问
提示编辑器不包含一个主要类型
追答
包名java1.a
你用下面这个代码吧
package java1.a;
import java.util.*;
public class Test {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Please input the age for a student:");
int ageOfStudent = scanner.nextInt();
System.out.println("Is greater than 18?"+ (ageOfStudent >= 18 ? "yes" : "no"));
}
}
展开全部
public class Test {
public static void main(String[]args){
Scanner scanner= new Scanner(System.in);
System.out.print("请输入学生年龄:");
int ageOfStudent = scanner.nextInt();
System.out.println("该生是否满18岁?"+
(ageOfStudent>=18?"yes":"no"));
}
}
顺带注意类名
public static void main(String[]args){
Scanner scanner= new Scanner(System.in);
System.out.print("请输入学生年龄:");
int ageOfStudent = scanner.nextInt();
System.out.println("该生是否满18岁?"+
(ageOfStudent>=18?"yes":"no"));
}
}
顺带注意类名
本回答被网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Scanner scanner= new Scanner(System.in);
追问
加了 Scanner scanner= new Scanner(System.in); 这条也报错啦!
追答
把你这类名改一下。。和Scanner重名了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Scanner scanner= new Scanner(System.in);
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询