java - Why does javac create <init> method in class that doesn't create any instance -


i have question related java compiler.

example code:

public class theclass {     public static void main(string[] args)     {         system.out.println("hello world!");     } } 

when compile class can see in javaclassviewer, class contains <init> method invokes java.lang.object construcotr, not creating instance of class , no constructor called. enter image description here jvm calls static method main, doesn't create instance of class. so, why compiler produces <init> method? understand if create object of theclass

the jls requires default constructor generated:

8.8.9. default constructor

if class contains no constructor declarations, default constructor implicitly declared.

also:

i not creating instance of class

irrelevant. compiler can't know that.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

c++ - Clear the memory after returning a vector in a function -

erlang - Saving a digraph to mnesia is hindered because of its side-effects -