Lecture 01 - 01/18
- Data Structures
- Design, build, test, debug large programs
- Use programming tools
- git, IntelliJ, JUnit, cmd line tools
About Java Code:
- Every Java file must contain class declaration
- All code lives inside a class, including helper functions, global constants, ...
- We define classes with "
- To run Java program, typically define main method using:
public static void main(String args)
- Statements end with semi-colons
- Instead of indentation, we use
- Must declare variables before use
- Variables must have declared type, and that type is permanent
- Compiler checks that all types in program (variables, expressions) are comaptible before the program ever runs
- Unlike Python, where type checks are done during execution
- Functions must be declared as part of a class in Java. Thus, all Java functions are methods.
- Define functions with "
public static" (for now)
- All parameters of a function must have a type
- Functions must declare their return type
- Java functions only return one value
Reflections on Static Typing:
- Catches some errors and makes it easier to debug
- Type errors almost never occur on user end
- Easier to read code
- Code runs more efficiently, no need for expensive runtime checks
- Code more verbose
- Code less general
- Way around in Java (generics)