Java - Java Building Blocks

Objectives: Working with Java Primitive data types and String APIs Declare and initialise variables (including casting and promoting primitive data types) Identify scope of variables Use local variable type inference Describing and Using Objects and Classes Declare and instantiate Java Objects, explain objects’ lifecycles (including creation, dereferencing by reassignment, and garbage collection) Read or write to object fields Create Objects Calling Constructors 1 Park p = new Park(); Park is the type, p is the variable name.

Java - Welcome to Java

Java Environment The Java Development Kit (JDK) contains the minimum software you need to do Java development, which includes javac java jar javadoc jlink The JRE was a subset of the JDK that was used for running a program but could not compile one. Integrated development environment (IDE) Change default java version in mac system: list all java versions in your system: /usr/libexec/java_home -V change to above version: export JAVA_HOME=`/usr/libexec/java_home -v <version no>` Identify the benefit of Java: Object-Oriented (vs Functional Programming) Encapsulation (access modifiers) Platform Independent (interpreted language vs compiled language) Robust (automatic garbage collection, it prevents memory leaks) Simple (no pointers, no operator overloading) Secure (Java code runs inside the JVM) Multithreaded Backward Compatibility (make sure old programs will work with later versions of Java.