Title: Java Fundamentals Summary
Course: CPS 161: An Intro to Programming with Java - DL MM MASTER

Java Fundamentals Summary

Java Historical Roots

- Machine Language Stage
- First Languages: Fortran and Cobol
- Languages providing some structure: Pascal and "C"
- Object Oriented languages and their relationships: C++, Java, C#, Objective C
- Java Programming Model: "Write once in Java and run it on any platform that has a JVM program"
- Microsoft Model: "You can program in any language you want as long as you run on a Microsoft platform"

Java Characteristics

- Open-source, and portable
- Environments: Web Servers (J2EE), Android, Browsers(Applets), and many other environments
- Execution Environment is protected (Java doesn't allow error prone things)
- Java is very Object Oriented, and contains many already built packages of powerful classes.
- When is Java a good choice and when would it be better to consider a non-interpreted language like C/C++.

Basics Hello World Comments

- Best to have class name and the file name match(pay attention to case)
- Program execution requires:
  - public static void main(String[] args)
- System.out.println and System.out.print
- Keyboard input requires something like:
  - Scanner keyboard = new Scanner(System.in);
- Importing packages like the Scanner require something like:
  - import java.util.Scanner;
- User's input can be returned from the Scanner keyboard with calls to:
  - keyboard.nextLine(), keyboard.nextInt(), etc.

Basics Simple Arithmetic

- Java is case sensitive, and white space insensitive.
- Comment rules (// and /* ... */ approaches)
- Variable declarations
- In Java the "=" sign means: store the contents of the right hand side into the variable on the left hand side
- Java supports most normal algebraic expressions (note that "*" is needed to signify multiply)

Basics Other Primitives

- Characteristics of the integer-like primitives: byte, short, int, and long
- Characteristics of the floating point primitives: float, and double
- Characteristics of the primitive char for text
- Characteristics of the primitive boolean

Basics Variables

- Rules for defining variables
- Naming conventions for "multi-word" variable names
- Naming conventions for Classes and Constants

Arithmetic Precedence, and Mixed Types

- Integer arithmetic using the basic operators +, -, *, /, %
- Floating Point arithmetic
- Operator precedence rules and using parentheses to change the order of operations
- Arithmetic using a mix of integers and floating point values

Arithmetic Primitive Sizes, Casting, Shortcuts

- Primitive size ordering: byte, short, int, long, float, double
- Storing smaller primitives into larger primitives
- Storing larger primitives into smaller primitives using casting operations
- The "=" shortcuts: +=, -=, *=, /=, %=
- More shortcuts(++, --): Post Increment, pre increment, post decrement, pre decrement

Last Modified: May 30, 2014 10:55 PM