Can't Java support standalone function without any class? | Sololearn: Learn to code for FREE!


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??

12/8/2019 12:53:35 PM


3 Answers

New Answer


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.


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


Functions is the same as method. In Object oriented programming, people call it method and function otherwise. Anthony, there's a rule for every programming languages that you must follow, known as syntax. for a java application to run, everything must be inside a class and that's it syntax