Classes don't have keyword "new" as a personal method or anything like that. It is the Java language itself that has the keyword "new". So in other words you put "new" in the code the compiler would recognize it and instantiate a new Object.

http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.9- this link is the documentation of Java language, in section 3.9 it shows all the keywords.

Edit: Like others are saying, what the snippet of code in your question indicates an inner class, so for instance, like it says in http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

public class ShadowTest {

public int x = 0;

class FirstLevel {

    public int x = 1;

    void methodInFirstLevel(int x) {
        System.out.println("x = " + x);
        System.out.println("this.x = " + this.x);
        System.out.println("ShadowTest.this.x = " + ShadowTest.this.x);
    }
}

public static void main(String... args) {
    ShadowTest st = new ShadowTest();
    ShadowTest.FirstLevel fl = st.new FirstLevel();
    fl.methodInFirstLevel(23);
}
}

The following is the output of this example:

x = 23
this.x = 1
ShadowTest.this.x = 0

This shows that the innerclass or class B(FirstLevel) is like or similar to the outer class's variables and methods(for it is associated with the instance of the outer class) of class A(ShadowTest).

Answer from Rika on Stack Overflow
🌐
Oracle
docs.oracle.com › javase › tutorial › java › nutsandbolts › _keywords.html
Java Language Keywords (The Java™ Tutorials > Learning the Java Language > Language Basics)
You cannot use any of the following as identifiers in your programs. The keywords const and goto are reserved, even though they are not currently used. true, false, and null might seem like keywords, but they are actually literals; you cannot use them as identifiers in your programs.
🌐
W3Schools
w3schools.com › java › java_ref_keywords.asp
Java Keywords
Access Modifiers Non-Access Modifiers Java Encapsulation Java Packages / API Java Inheritance Java Polymorphism Java super Keyword Java Inner Classes Java Abstraction Java Interface Java Anonymous Java Enum
Discussions

What are Keywords in Java? - Stack Overflow
I am curious about keywords in Java. Should I understand it as a class of various methods that get created with every instance of user-defined classes, like the ultimate “super” class? How is it More on stackoverflow.com
🌐 stackoverflow.com
Need a detailed understanding of the keywords in the beginning of any java programming.
void means the method doesn't return a value. You can have a method declared void kickRocks() and if it is void, you can just call it. It doesn't provide a value, it just kicks the rocks. kickRocks(); If you have a method that does return a value, then it needs to return that value. int breakRocks() may return how many rocks are broken. You can use that value. count = count + breakRocks(); Or you can ignore the return value. breakRocks(); But either way, it needs to fulfill its return value. Static has more than one place it might get used, but for fields or methods, it means that thing belongs to the class itself and not the instances of the class. Your Rocks class allows rocks of three sizes, so when you make a Rock myRock = new Rock(RockSize.SMALL), you get an instance of Rock that probably has a field that stores its size. Each instance of a Rock gets its own size. However, if the Rock class also needs to keep a list of all rocks and let you know how many rocks have been made, that list isn't a separate list for each instance of a rock, its for the class itself, so that list is static, which means there is only one list, not a seperate rock list for each rock. String[] args is an array of strings so if the program is run from the command line, it can access all the arguments passed in that command line. If you aren't running your stuff from a command line, you can probably just ignore the args. It needs to be there, but you don't have to use them. More on reddit.com
🌐 r/javahelp
3
1
December 29, 2021
Add or modify keywords in java language - Stack Overflow
I know my question does not seem valid, but it is genuine. When writing java I must use the word import so as to import classes from classpath. It is required to user new to initiate certain object... More on stackoverflow.com
🌐 stackoverflow.com
Java Keywords
what is the use of volatile keyword? need example with explanation? More on youth4work.com
🌐 youth4work.com
8
0
April 1, 2020
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-keywords
Java Keywords - GeeksforGeeks
1 month ago - In Java, keywords are the reserved words that have some predefined meanings and are used by the Java compiler for some internal process or represent some predefined actions.
🌐
Wikipedia
en.wikipedia.org › wiki › List_of_Java_keywords
List of Java keywords - Wikipedia
October 20, 2025 - In the Java programming language, a keyword is any one of 68 reserved words that have a predefined meaning in the language. Because of this, programmers cannot use keywords in some contexts, such as names for variables, methods, classes, or ...
Top answer
1 of 3
2

Classes don't have keyword "new" as a personal method or anything like that. It is the Java language itself that has the keyword "new". So in other words you put "new" in the code the compiler would recognize it and instantiate a new Object.

http://docs.oracle.com/javase/specs/jls/se7/html/jls-3.html#jls-3.9- this link is the documentation of Java language, in section 3.9 it shows all the keywords.

Edit: Like others are saying, what the snippet of code in your question indicates an inner class, so for instance, like it says in http://docs.oracle.com/javase/tutorial/java/javaOO/nested.html

public class ShadowTest {

public int x = 0;

class FirstLevel {

    public int x = 1;

    void methodInFirstLevel(int x) {
        System.out.println("x = " + x);
        System.out.println("this.x = " + this.x);
        System.out.println("ShadowTest.this.x = " + ShadowTest.this.x);
    }
}

public static void main(String... args) {
    ShadowTest st = new ShadowTest();
    ShadowTest.FirstLevel fl = st.new FirstLevel();
    fl.methodInFirstLevel(23);
}
}

The following is the output of this example:

x = 23
this.x = 1
ShadowTest.this.x = 0

This shows that the innerclass or class B(FirstLevel) is like or similar to the outer class's variables and methods(for it is associated with the instance of the outer class) of class A(ShadowTest).

2 of 3
0

As all the languages ,Java has Keywords. Here the new keyword is used for initialization purposes.here the object of the class A is initialised in the first statement. in second statement the object of class B is initialised with class A's object A

🌐
Igmguru
igmguru.com › blog › java-keywords
Java Keywords – 68 Java Keywords Explained
4 weeks ago - Java Keywords are 68 reserved words that have predefined meanings and cannot be used for variables, methods, or identifiers. Learn them all with this comprehensive guide.
Find elsewhere
🌐
DataCamp
datacamp.com › doc › java › category › keywords
Java Keywords
In Java, keywords are reserved words that have a predefined meaning in the language. They form the foundation of Java's syntax and cannot be used as identifiers, such as variable names, method names, or class names.
🌐
Reddit
reddit.com › r/javahelp › need a detailed understanding of the keywords in the beginning of any java programming.
r/javahelp on Reddit: Need a detailed understanding of the keywords in the beginning of any java programming.
December 29, 2021 -

I understand that all programming need to start with

 public class Test {

      public static void main(String[] args){

           }
      }

But after searching and reading many articles and watching videos I still don't understand why we need static, void, String[] args, and why when we change void to a primitive or reference type we need to have a return 0;. why don't we need that when its a void?

Every book I read, class I attended, or video I've watched, none ever fulfilled my understanding of those things and I cant move forward when I don't understand what is happening from the beginning.

Top answer
1 of 3
5
void means the method doesn't return a value. You can have a method declared void kickRocks() and if it is void, you can just call it. It doesn't provide a value, it just kicks the rocks. kickRocks(); If you have a method that does return a value, then it needs to return that value. int breakRocks() may return how many rocks are broken. You can use that value. count = count + breakRocks(); Or you can ignore the return value. breakRocks(); But either way, it needs to fulfill its return value. Static has more than one place it might get used, but for fields or methods, it means that thing belongs to the class itself and not the instances of the class. Your Rocks class allows rocks of three sizes, so when you make a Rock myRock = new Rock(RockSize.SMALL), you get an instance of Rock that probably has a field that stores its size. Each instance of a Rock gets its own size. However, if the Rock class also needs to keep a list of all rocks and let you know how many rocks have been made, that list isn't a separate list for each instance of a rock, its for the class itself, so that list is static, which means there is only one list, not a seperate rock list for each rock. String[] args is an array of strings so if the program is run from the command line, it can access all the arguments passed in that command line. If you aren't running your stuff from a command line, you can probably just ignore the args. It needs to be there, but you don't have to use them.
2 of 3
3
The JVM needs some standardized protocol to start a program and that's just the protocol the JVM designers decided on. The main returns void, because the JVM doesn't do anything with the return value. There better more flexible ways to return status to the JVN. The main function is declared static because the JVM doesn't want to create an object to start a program, it just wants to call a function. The String[] args parameter is simply the structure that the JVM passes command line parameters to the starting program. Any parameters the JVM doesn't recognize as belonging to it's self it will pass as a String array.
🌐
Programiz
programiz.com › java-programming › keywords-identifiers
Java Keywords and Identifiers
Become a certified Java programmer. Try Programiz PRO! ... Keywords are predefined, reserved words used in Java programming that have special meanings to the compiler.
Top answer
1 of 7
11

One approach that uses a rather sophisticated toolchain and could be considered as an "overkill", but is not as much effort as writing an own compiler or so:

  • Download ANTLR4 from http://www.antlr.org/download.html
  • Download the Java Grammar at https://github.com/antlr/grammars-v4/blob/master/java/Java.g4
  • Modify the Java Grammar according to your needs...
  • Run

    java -classpath "antlr-4.4-complete.jar" org.antlr.v4.Tool Java.g4
    

    This will generate some files, one of them being JavaLexer.java.

  • Create a Java Project that contains the ANTLR JAR and the JavaLexer.java
  • Create a class like the following, which does the translation:

    import java.io.IOException;
    
    import org.antlr.v4.runtime.ANTLRFileStream;
    import org.antlr.v4.runtime.CharStream;
    import org.antlr.v4.runtime.CommonTokenStream;
    import org.antlr.v4.runtime.TokenStream;
    
    public class Main {
        public static void main(String[] args) throws IOException {
            CharStream s = new ANTLRFileStream("Input.javaX");
            JavaLexer lexer = new JavaLexer(s);
            TokenStream t = new CommonTokenStream(lexer);
            int i = 1;
            while (true) {
                if (t.LA(i) == -1) {
                    break;
                }
                if (t.LA(i) == JavaLexer.IMPORT) {
                    System.out.print("import ");
                } else {
                    System.out.print(t.LT(i).getText() + " ");
                }
                i++;
            }
        }
    }
    

    (of course, this is only an example that only translates the IMPORT token, which was defined in the grammar file to be "uvoziti". For a more general and flexible translation, one would define the translation in an external file, and probably read this file to create a map Map<Integer, String> that maps JavaLexer.IMPORT to "import" etc...)

  • Create the input file from the example: Input.javaX:

    uvoziti java.io.File;
    
    public class Input
    {
        public static void main(String args[])
        {
            File file = null;
            System.out.println("done");
        }
    }
    

    When you then run the Main, it will read this input file, eventually find the IMPORT token, and instead of the original text (uvoziti) it will print import.

  • The result will be the contents of a Java file, with an awful formatting...

    import java . io . File ; public class Input { public static void main ( String args [ ] ) { File file = null ; System . out . println ( "done" ) ; } } 
    

    but fortuntately, the compiler does not care about the formatting: You may write this output directly to a .java file, and the compiler will swallow it.

As it is described here, it is only a proof of concept. For a flexible and generic translation of many (all) keywords, one would have to build some infrastructure around all that. The input files should be read automatically (File.listFiles(), recursively for packages). Each of them would have to be translated (using the Map<Integer, String> that I mentioned earlier). Then the output files would have to be written and compiled, either with the runtime JavaCompiler, or by manually invoking the javac with Runtime#exec.

But in general, I think that this should be doable within a few hours in the best case, and within one week when considering that everything takes longer than you think.

Writing an own Java compiler, on the other hand, might take a bit longer, even when you consider that everything takes longer than you think...

2 of 7
0

Java doesn't provide any way to redefine keywords.

If you add or remove keywords to the Java language, then it isn't Java anymore.

You could write your own language that compiles to Java. This could be as simple as writing a program that does a string replace of uvoziti for import and then runs it through the javac compiler.

🌐
Upgrad
upgrad.com › home › blog › software development › a complete guide to java keywords
A Guide to Java Keywords: What You Need to Know!
August 7, 2025 - Other Important Keywords: Such as static, final, abstract, synchronized, and volatile modify how your classes, methods, and variables behave. ... Java has recently added some new Java language keywords for its development.
🌐
Unstop
unstop.com › home › blog › java keywords explained | list of 54 keywords +code examples
Java Keywords Explained | List Of 54 Keywords +Code Examples // Unstop
December 12, 2024 - Keywords in Java are reserved words with predefined meaning and functionality that cannot be used for anything else. Examples: class, int, if, for, while, etc.
🌐
ThoughtCo
thoughtco.com › reserved-words-in-java-2034200
Reserved Words in Java
January 27, 2019 - This is a full list of the 53 keywords reserved in Java that cannot be used as object or variable names.
🌐
Great Learning
mygreatlearning.com › blog › it/software development › java keywords
Master Java Keywords: A Detailed List with Examples
June 27, 2025 - Leverage OOP Keywords: Use class, extends, implements, abstract, and interface to design robust object-oriented systems. This promotes code reusability and maintainability. To test the understanding more better, take Java Quiz.
🌐
Study.com
study.com › courses › business courses › java programming tutorial & training
Java Keywords: Protected, Public & Private | Study.com
In this lesson, we'll cover the concepts and the code presented will revolve around a hypothetical program that works with employee information. Public, protected, and private are the keywords used when you declare a variable or a method.
🌐
TechVidvan
techvidvan.com › tutorials › keywords-in-java
Keywords in Java - Java Reserved Words - TechVidvan
June 5, 2020 - Java Keywords - What are keywords in java and list of java keywords with examples - boolean, short, for, case, catch,final,interface,protected, this, byte
🌐
W3Schools
w3schools.com › java › ref_keyword_do.asp
Java do Keyword
Access Modifiers Non-Access Modifiers Java Encapsulation Java Packages / API Java Inheritance Java Polymorphism Java super Keyword Java Inner Classes Java Abstraction Java Interface Java Anonymous Java Enum
🌐
Medium
medium.com › @TechiesSpot › java-keywords-an-in-depth-guide-19f1504b3686
Java Keywords: An In-Depth Guide. In the world of Java programming… | by Techie's Spot | Medium
January 22, 2024 - In the world of Java programming, keywords are the building blocks of the language. These reserved words have specific meanings and are…
🌐
Youth4work
youth4work.com › talent › core java › forum › java keywords
Java Keywords
April 1, 2020 - A Java keyword is one of 50 reserved terms that have a special function and a set definition in the Java programming language. The fact that the terms are reserved means that they cannot be used as identifiers for any other program elements, ...
🌐
Quora
quora.com › How-many-keywords-are-in-java
How many keywords are in java? - Quora
Answer (1 of 5): Around 50 abstract boolean break byte case catch char class const continue default do double else extends final finally float for goto if implements import instanceof int interface long native new package private protected public return short static strictfp super switch s...