-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNotes0912.txt
More file actions
41 lines (28 loc) · 960 Bytes
/
Notes0912.txt
File metadata and controls
41 lines (28 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
Aim: What does a java program look like?
Do Now: Log in, open a terminal and use emacs to write the
simple java program we say at the end of class
yesterday. Then try to compile and run it!
In case you missed it:
public class Hello {
public static void main(String[] args) {
System.out.println("Good News Everyone!");
}
}
Java Syntax Basics:
Java is case sensitive!
The class name must match the file name
ex. Hello.java must define a class called Hello
Regular statements must end in a ;
Code blocks are contained inside {}
{ replaces ; at the end of a line that starts a code block
} sets the end of the code block
Examples of code blocks
Method bodies
Class bodies
Conditional (if, else...) statement results
Looping processes.
Comments
// can be used to comment a single line
ex. //This will print to the command line
System.out.println("boo"); //scary
/* .. */ can be used to comment multiple lines