Let's have a cup of coffee (Java)

Basics of the Java Programming language

Step One: Installations

  • Links in the content
  • http://www.wikihow.com/Install-Oracle-Java-on-Ubuntu-Linux (For Ubuntu)
  • http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html (For Windows)

 

NB: Make sure you download the right JDK for the right architecture

How it works

Understanding Data Types

Data Types in Java

  • Strings
  • Numbers (Byte, Integers, Floats, Doubles)
  • Boolean
  • Arrays, ArrayLists
  • Hashmaps

Java is a strongly typed language

int x = 40;

String people = "Who exactly?";

Array names[] = ["John", "Andrew", "Peter"]

Primitive

  • Not Objects
  • Cannot have methods called on them
  • Consumes less memory on runtime
  • Example: int

Wrapper Classes

  • Are Objects
  • Have inbuilt Java methods that can be called on them
  • Consumes more memory on runtime
  • Example: Integer

VS

The glory of the main method

public static void main(String[] args){

//Your code here
//Where it all begins :)

}

The Setup

public class CoreFour{

   public static void main(String[] args){

     //This is one amazing class

   }

}

Control Flows and Operators

Definition

  • Control flow === Branching == Adding logic to your code
  • Operators: manipulate the data and also aids in adding logic to your code

Let's have some CTRL

  • Conditional Statements

  • Looping Statements/Iteration

Conditional Statements

  • If...else if...else

  • switch...case

  • Ternary operator "?"

Looping Statements

  • for(start; end; stepsize)

  • for(variable : data)

  • do...while

  • while

Common Operators

  • Assignment: =
  • Logical comparison: ==
  • Logical OR: ||
  • Logical AND: &&
  • Modulus: %
  • Greater than: >
  • Less than: <

Classes vs Objects

Definition of Terms

  • Class: Blueprint of an object. Contains both state and behaviour
  • Object: Instance of a class
  • Method: Contains behaviour. May limit access using the access modifiers
Made with Slides.com