Search code examples
javamethods

Difference Between Classes And Methods in Java


I am learning how to code with Java. What is the difference between a class and a method, and which is which in the following code?

package template;
public class Template {
    /**
     * @param args the command line arguments
     */
    private static class BGCode {
        public BGCode() {
        }
    }
}    

Solution

  • The second question is easy to answer: the things called class are classes. (i.e. class Template and class BGCode) There are no actual methods, only a constructor (-> public BGCode) which is similar to a method but not the same. I don't want to confuse you too much, so here is an article about this topic.