This question is an exact duplicate of:
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 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.
For more information: https://docs.oracle.com/javase/tutorial/java/nutsandbolts/index.html
System is a final class from
java.lang package
.out is the reference of
PrintStream
class and a static member ofSystem
class.print is a method of
PrintStream
class.Have a look at this too.. https://docs.oracle.com/javase/7/docs/api/java/lang/System.html