Home > Back-end >  Java object creation
Java object creation

Time:11-03

When using the class name when creating objects, when using the class name?

CodePudding user response:

Java object creation: the name of the class reference name=new class name (); Java object creation by new keywords, followed closely behind the new keyword is a class name + (), to call, no arguments constructor of the class can also be called a no-parameter constructor, the actual need, for your main class name is a what thing, really haven't heard,

CodePudding user response:

Your so-called master class name refers to the same Java file have more than one class, with a public statement that class? Or say that nested inner class of class, outside class is the main class?
No matter you are the main class or the main class, create an object is a new package name. The name of the class (); (or use reflection, is too deep to LZ, there is no mention of the), if it is in the same package or import the package, the package name can be omitted, if it is internal static class, the class name to include external class (namely the external class. Internal class name), if it is within the static class, the class name to include external instance of a class (that is, class called new external classes (). The internal name of the class)
  • Related