COMPSCI 61B Lecture Notes - Lecture 2: Instance Variable, Init, Javac
Document Summary
Java file needs the class file to run. Cat command - prints out what is in the file. Not the only way to run java code. Why make a class file at all. class has been type checked, distributed code is safer. class files are simpler for machines to execute, distributed code is faster. Protects intellectal property, no need to give out source. Without a main method, program won"t run. If you put back public static void main. Often the case that classes don"t have main methods. Often have classes that use methods from classes. Every method in java must be associated with a class. If you want to run a class, need to define a main method. Can"t run dog class directly, but can define main method in other class that calls methods from this class. Dog class can serve as an object, serve as blueprint for other dogs. Non-static variable cannot be referenced in static context.