i. Compiled language: different compiler for different types of processors
ii. Interpreted language – eg Java – compile to Java Byte Code, then Java Virtual Machine (JVM) converts to machine code on the fly when you run the program.
i.
Source.java
– program file (source code)
ii. Source.class – byte code
i. Some hand-waving here – public static void main(String[] args)
ii. We’ll talk about what those words mean later.
System.out.println(“text”);
i. Java is case sensitive. “System” is different than “system” (and “system” wouldn’t actually work).
i. This is the technical term for things that we want to treat as text. The following are all strings:
ii. “Hello”
iii. “Hello World!”
iv. “1+2”
i. We can print numbers by omitting the “” in println(“text”);
ii. For example: System.out.println(1);
iii. If we do this, it’s important to only include numbers. The following will not work:
1. System.out.println(hello!);
iv. We can do Math with numbers and operators within println statements:
1. for instance, System.out.println(1+1);
i. Syntax error – cannot compile due to misspelling etc.
1. System.ou.println(“Hello World”);
i. Logical error
1. System.out.println(“Hello Word!”);
2. Note – world is misspelled, but Java doesn’t know this J. So the program still runs, just doesn’t give desired output.
ii. Run-time exception
1. System.out.println(1/0);
2. Because we can’t divide by zero. So, the program will compile ok, but crash when we run it.
i. Not ok:
System.out.println(“Hello World”)
ii. Ok:
System.out
.println(1+2+"3"+
4+5);
iii. Not ok –
System.out.print
ln(1+2+"3"+
4+5);