Howdy. 

public class Elementary {
  public static void main(String[] args) {
    System.out.println(12345 + 5432l);
  }
}

Yesterday we talked about BigDecimals. 

We also created Scanners.

What other objects could we look at right away? 

In java we have two kinds of types: 

  (a) primitive types: numbers, booleans and characters
                       int    double  boolean  char
                       byte   float 
                       long
                       short 

  (b) reference types (user-defined types, classes)

                       java.util.Scanner 
                       javax.swing.JFrame
                       java.math.BigDecimal


import javax.swing.*; 

public class Thursday {
  public static void main(String[] args) {
    Integer a = new Integer(23); 
    System.out.println( 2 * a ); 
  }
}

Where is Jerry Haoxuan Shen? 

import javax.swing.*; 

public class Thursday {
  public static void main(String[] args) {
    JFrame fido; // declare a variable 
    fido = new JFrame(); // instantiate such an object 
    System.out.println( fido ); 
    fido.setVisible(true); 
    fido.setSize(300, 400);
  }
}

So what are we supposed to be left with at the end of chapter 3? 

Variables are: 

  static variables
  instance variables
  parameters 
  local variables 

The last two occur in methods. 

For all practical purposes it does not matter if the methods are
static or not static. But static methods are there for us immediately
(in the class) while instance members requires an extra step (new) so
we will use static methods in our examples below. 

public class David {
  public static void main(String[] args) {
    for ( String arg : args ) {
       System.out.println( arg ); 
    }
  }
}


Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop
> run David
> java David Arif 
Arif
> java David Arif Teague Kevin 
Arif
Teague
Kevin


More standard types of loops: 

We need to discuss arrays vs. ArryLists:

http://www.cnn.com/2016/06/20/europe/stephane-malka-paris-architecture/

import java.util.Arrays; 

public class Joseph {
  public static void main(String[] args) {
    int a; // declaration 
    a = 4; // initialization 
    System.out.println( a ); // using it in some fashion
    String b; // declaration 
    b = null; // initialized now with nothing 
    String d = "10gen"; 
    System.out.println( d.charAt(1) + 2 ); // should print 50
    System.out.println( (char) ("whatever".charAt(1) + 2) ); // prints j        
    int[] c ; // declaration
    c = new int[4]; // allocation 
    System.out.println( Arrays.toString( c )); 
    c[2] = 19;
    c[1] = -3; 
    c[0] = 5; 
    c[c.length - 1] = 7;
    System.out.println( Arrays.toString( c )); 
    // https://docs.oracle.com/javase/8/docs/api/java/util/Arrays.html#copyOf-int:A-int-
    c = Arrays.copyOf(c, c.length + 1); 
    System.out.println( Arrays.toString( c )); 
    c[c.length - 1] = 2;    
    Arrays.sort( c ); 
    System.out.println( Arrays.toString( c ));     
    boolean[] e = new boolean[6]; 
    System.out.println( Arrays.toString( e ));         
  }
}

So this essentially finishes Chapter 03. 

It also sets you up for Homework 03. 

I will have a review posted for Monday re: Chapter 03 though. 

Next week: Chapter 4 (Modeling). 

See you in lab!

--