Java programming main method in class -
sorry naive question. learn programming in java , have question on beginning.
i follow lesson: closer @ "hello world!" application, can found following code.
class helloworldapp { public static void main(string[] args) { system.out.println("hello world!"); // display string. } }
having experience in programming in c++ code me looks rather bizarre.
class helloworldapp contains starting point application, me looks strange, because of many points, example, in order work thought need somehow evoke method main because in class, works is. if have several classes (nor not sure if it's ok in java app? but, in general should ok), define several starting points in app?
what reason define staring point class?
java not c++. c++ had preserve backwards compatibility c, although object oriented language still has elements of procedural language including stand alone independent functions. example function main(int argv, char ** arc)
entry point c (and therefore c++) program.
unlike c++ java defined scratch pure object oriented language. therefore there no functions there. replaced methods must belong class. there static
methods useful. 1 example main()
method. indeed need entry point program before instance of class created. perfect solution choosed java programming language designers specify special method main()
signature public static void main(string[] args)
used jvm entry point program.
Comments
Post a Comment