Java Overview

Photo by Nathan Dumlao on Unsplash
Photo by Nathan Dumlao on Unsplash

Introduction to Java

Java is a high-level, general-purpose, compiled programming language. Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of computer architecture.  It is intended to let application developers “write once, run anywhere” (WORA), meaning that compiled Java code can run on all platforms that support Java without the need for recompilation.


Java was originally developed by James Gosling at Sun Microsystems (which has since been acquired by Oracle Corporation) and released in 1995 as a core component of Sun Microsystems’ Java platform. The language derives much of its syntax from C and C++, but it has fewer low-level facilities than either of them. The original and reference implementation Java compilers, virtual machines, and class libraries were originally released by Sun under proprietary licenses. As of May 2007, in compliance with the specifications of the Java Community Process, Sun relicensed most of its Java technologies under the GNU General Public License.

Java Resources

Quick Reference – Java

Here is a quick reference for the basics of Java…

Hello World in Java

public class App {
  public static void main(String[] args) { 
    System.out.println("What is your name?");
    try {
      BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(;
      String yourName = bufferedReader.readLine();
         System.out.println("Hello " + yourName + "!");
     } catch(IOException e) {

Java: Basic Syntax

Variables & Data Types

Wrapper classes provide methods like .parseInt() or .toString(). Primitives are more efficient.

Primitives    Wrapper classes
  boolean       Boolean
  byte          Byte
  short         Short
  int           Integer
  long          Long
  float         Float
  double        Double
  char          Character, String


Note: == applies only to numbers, so to compare strings (or other objects), use string1.equals(string2)

if (condition) {
  // do something
} else if (condition) { 
  // do something else
} else { 
  // do something else

Switch statements:

int var = 0;

switch(var) {
  case 1:  // do first thing
  case 2:  // do second thing
  default: // what to do if nothing matches...


Note: You cannot change the length of an array after it is declared.

int[] primeNumbers = { 2, 3, 5, 7, 11 };

Array Lists

import java.util.List;
import java.util.ArrayList;

List primeNumbers = new ArrayList {2, 3, 5, 7, 13};
primeNumbers.get(1); //returns 3 in this case...

Hash Maps

import java.util.Map;
import java.util.HashMap;

Map<String, String> mapName = new HashMap<string, string>();


You can loop through all the items in an array:

string[] myList = {"one", "two", "three", "four", "five"};

for (String item : myList) {

You can loop a fixed number of times:

for (int i = 0; i < 5; i++) {

You can loop while a condition is true:

while (true) {
  // do something that may change the condition

You can loop until a condition is false (always loops once):

do {
  // do something that may change the condition
} while (true);

Java: Object-Oriented Syntax


Classes are defined in a file with the same name. All names must be uppercase:

class Animal {
  public string Species;
  public string Name;
  public string Sound;


Animal myPet = new Animal();

myPet.Species = "dog";
myPet.Name = "Fido";
myPet.Sound = "Bow-wow";


class MyCalculator {
  public int Add(int num1, int num2) {
    return num1 + num2;


class Animal {
  public string Species;
  public string Name;
  public string Sound;

  public Animal(string species, string name, string sound) {
    Species = species;
    Name = name;
    Sound = sound;

Animal myPet = new Animal("dog", "Fido", "Bow-wow");
Animal yourPet = new Animal("cat", "Garfield", "Screech! Hiss!");

Favorite Books on Java

About the author


Karen Freeman-Smith lives near Portland, OR with her partner, two grown children (in and out of the basement), and a cat named Shiva. Karen maintains two personal websites as well as several topical websites about: Programming, Web Development, Foreign Languages, International Students, Fiction Writing, and Typing.
You cannot copy content of this page