We have learned standard library methods in 2.5. The other category of methods (a.k.a functions) are user-defined methods.
B. Watch (PPT)
- What is a static method in Java?
Java is an object-oriented programming language but so far we have not used object-oriented concepts such as instances of a class. A "static" method means the method belongs to the class, not an instance of the class. For instance "main" is the start of all other methods, it is static. All the methods we create for now are static.
2. Where should I define my methods?
Inside the class but outside main, either before main or after main. The order doesn't matter, a method has to be called by main to run.
Create a static method outside main to return the average of an array of double values.