英文:
(Java) Variable names must match pattern?
问题
import java.util.Scanner;
public class ComparingNumbers {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int FirstNum = Integer.valueOf(scanner.nextLine());
int SecondNum = Integer.valueOf(scanner.nextLine());
if (FirstNum > SecondNum) {
System.out.println(FirstNum + " is greater than " + SecondNum + ".");
} else if (FirstNum < SecondNum) {
System.out.println(FirstNum + " is smaller than " + SecondNum + ".");
} else {
System.out.println(FirstNum + " is equal to " + SecondNum + ".");
}
}
}
Line 9: 变量名 'FirstNum' 必须匹配模式 '^[a-z][a-zA-Z0-9]$'。
Line 10: 变量名 'SecondNum' 必须匹配模式 '^[a-z][a-zA-Z0-9]$'。
我的变量名有什么问题吗?作为一个初学者,简单的回答将会非常感激。
英文:
import java.util.Scanner;
public class ComparingNumbers {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int FirstNum = Integer.valueOf(scanner.nextLine());
int SecondNum = Integer.valueOf(scanner.nextLine());
if (FirstNum > SecondNum) {
System.out.println(FirstNum + " is greater than " + SecondNum + ".");
} else if (FirstNum < SecondNum) {
System.out.println(FirstNum + " is smaller than " + SecondNum + ".");
} else {
System.out.println(FirstNum + " is equal to " + SecondNum + ".");
}
}
}
Line 9: Name 'FirstNum' must match pattern '^[a-z][a-zA-Z0-9]$'.<br/>
Line 10: Name 'SecondNum' must match pattern '^[a-z][a-zA-Z0-9]$'.
What is the issue with my variable names?. I am a beginner so a simple answer will be greatly appreciated.
答案1
得分: 1
Java变量名应采用驼峰式命名法。变量名应为firstNum和secondNum。
英文:
Java variable names should be camelCase. Variable names should be firstNum and secondNum.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论