COMPSCI 61B Lecture Notes - Lecture 2: Instance Variable, Init, Javac

26 views5 pages

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.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents