-
Book Overview & Buying
-
Table Of Contents
OCA: Oracle Certified Associate Java SE 8 Programmer I Study Guide: Exam 1Z0-808
By :
A Java program begins execution with its main() method. A main() method is the gateway between the startup of a Java process, which is managed by the Java Virtual Machine (JVM), and the beginning of the programmer's code. The JVM calls on the underlying system to allocate memory and CPU time, access files, and so on.
The main() method lets us hook our code into this process, keeping it alive long enough to do the work we've coded. The simplest possible class with a main() method looks like this:
1: public class Zoo {
2: public static void main(String[] args) {
3:
4: }
5:}
This code doesn't do anything useful (or harmful). It has no instructions other than to declare the entry point. It does illustrate, in a sense, that what you can put in a main() method is arbitrary. Any legal Java code will do. In fact, the only reason we even need a class structure to start a Java program is because the language requires it. To compile and execute this code...
Change the font size
Change margin width
Change background colour