+ 3

Can't Java support standalone function without any class?

I recently noticed this trend that every method of Java should be enclosed in a class first then it can be used like a normal function Is it true??

8th Dec 2019, 12:53 PM
Aditya
Aditya - avatar
2 odpowiedzi
+ 3
That is one of the reasons it is called a complete Object oriented programming language. Even the primitive data types have wrapper classes. Everything has to be declared and defined within a class.
8th Dec 2019, 4:17 PM
Avinesh
Avinesh - avatar
+ 3
The difference between a function and a method is that a function can be accessed from every part of the program, however a method can only accessed from a well defined class Java doesn't support function so we will have to keep working with classes
8th Dec 2019, 4:28 PM
amit avinoam
amit avinoam - avatar