问题描述
我研究了有关Java的知识,其中列出了50个Java关键字. Lex有一项作业,目的是识别单词是关键字,ID,符号,运算符.但是还有一个小问题是下面的代码,System.out.print()
中的print
是ID还是关键字?
I have studied about java which have listed 50 Java keywords. There is a homework of Lex, the goal is to recognize the word is keywords, IDs, symbols, operators. But there is one more little problem is the code below, is print
in System.out.print()
an ID or keyword?
public class HelloWorld {
public static int add(int a, int b) {
return a + b;
}
public static void main(String[] args) {
int c;
int a = 5;
c = add(a, 10);
if (c > 10)
System.out.print("c = " + -c);
else
System.out.print(c);
System.out.print("Hello World");
}
}
推荐答案
print是java.io.PrintStream类中方法的名称,因此是ID.关键字是在大多数IDE中键入它们时通常会变成蓝色或另一种颜色的关键字.
print is the name of a method in the java.io.PrintStream class, hence an ID. Keywords are those which generally turn blue or another colour when you type them in most IDEs.
有关更多信息: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html
这篇关于在Java编译器中,System.out.print中的打印可以定义为标识符或关键字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!