1) Programming Basics 1
a) Java and the Java Virtual Machine 3 1.1 Computers and Their Programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.1 The computer programs in your machine . . . . . . . . . . . . . . . . . . . . 3
1.1.2 Java Virtual Machines - JVM . . . . . . . . . . . . . . . . . . . . . . . . . . . 3
1.1.3 Code editing and code compiling . . . . . . . . . . . . . . . . . . . . . . . . . 6
b) Our First Programs 13
2.1 The First Program, "Hello, World!" . . . . . . . . . . . . . . . . . . . . . . . . . . . 13
2.1.1 Method declaration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.2 Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16
2.1.3 System.out.println and System.out.print . . . . . . . . . . . . . . . . . . 17
2.1.4 Spacing in the source code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
2.2 Commenting . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19
2.3 Errors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
2.4 Using Multiple Statements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23
- println versus print revisited . . . . . . . . . . . . . . . . . . . . . . . . . . 23
- Printing multiple-line texts on the screen . . . . . . . . . . . . . . . . . . . . 25
2.4.3 Escaping characters . . . . . . . . . . . . . . . . . .
About the Author: Mitsunori Ogihara is a professor of Computer Science at the University of Miami, Coral Gables, FL. Prior to joining the University of Miami, he was a professor of Computer Science at the University of Rochester, Rochester, NY. He is presently an editor of Theory of Computing Systems (Springer), International Journal of Foundations of Computer Science (World Scientific Press), and Open Computer Science Journal (De Gruyter). He has published three books: A Complexity Theory Companion (Springer), Music Data Mining (CRC Press), and one in Japanese. He has published more than 190 research articles.