系统无法解析或不是字段
System could not be resolved or is not a field
import java.util.Scanner;
public class problem6
{
public static void main(String[] args)
{
System.out.println("Please enter an integer:");
Scanner keyboard = new Scanner(System.in);
int number = keyboard.nextInt( );
if (number >= 100) ll (number >= 50 && number <= 75)
System.out.println("YES"); //here is the error
else
System.out.println("NO");
}
private static Object ll(boolean b) {
return null;
}
}
我不明白为什么但 eclipse 让我在我的程序中插入 "private static object...in order to use the "or" (ll)
System
未被识别,因为您的语法不正确。下面的代码向您展示了我认为您想要达到的目的。
import java.util.Scanner;
public class problem6
{
public static void main(String[] args)
{
System.out.println("Please enter an integer:");
Scanner keyboard = new Scanner(System.in);
int number = keyboard.nextInt( );
if ((number >= 100) || (number >= 50 && number <= 75)){
System.out.println("YES");
}
else {
System.out.println("NO");
}
}
}
布尔比较器 ||
不是两个小写的 L,而是两个管道。这就是 Java 对您写的内容不满意的原因。此外,您在原始代码中定义了一个 double-Ld 方法(我想您认为它是 ||
),因此您的代码试图被编译(英文)为...
if the number is greater than or equal to 100 <method call with a boolean argument> print "Yes"
对于java,这毫无意义。
行
if (number >= 100) ll (number >= 50 && number <= 75)
应该使用 'or' 运算符 ||
而不是 double-ell ll
.
此外,您需要将整个 if
表达式括起来,因为这也是必需的:
if ((number >= 100) || (number >= 50 && number <= 75))
如果某处代码不完整,就会出现这种错误。所以请彻底检查代码以解决这个问题。
import java.util.Scanner;
public class problem6
{
public static void main(String[] args)
{
System.out.println("Please enter an integer:");
Scanner keyboard = new Scanner(System.in);
int number = keyboard.nextInt( );
if (number >= 100) ll (number >= 50 && number <= 75)
System.out.println("YES"); //here is the error
else
System.out.println("NO");
}
private static Object ll(boolean b) {
return null;
}
}
我不明白为什么但 eclipse 让我在我的程序中插入 "private static object...in order to use the "or" (ll)
System
未被识别,因为您的语法不正确。下面的代码向您展示了我认为您想要达到的目的。
import java.util.Scanner;
public class problem6
{
public static void main(String[] args)
{
System.out.println("Please enter an integer:");
Scanner keyboard = new Scanner(System.in);
int number = keyboard.nextInt( );
if ((number >= 100) || (number >= 50 && number <= 75)){
System.out.println("YES");
}
else {
System.out.println("NO");
}
}
}
布尔比较器 ||
不是两个小写的 L,而是两个管道。这就是 Java 对您写的内容不满意的原因。此外,您在原始代码中定义了一个 double-Ld 方法(我想您认为它是 ||
),因此您的代码试图被编译(英文)为...
if the number is greater than or equal to 100 <method call with a boolean argument> print "Yes"
对于java,这毫无意义。
行
if (number >= 100) ll (number >= 50 && number <= 75)
应该使用 'or' 运算符 ||
而不是 double-ell ll
.
此外,您需要将整个 if
表达式括起来,因为这也是必需的:
if ((number >= 100) || (number >= 50 && number <= 75))
如果某处代码不完整,就会出现这种错误。所以请彻底检查代码以解决这个问题。