Howdy. 

public class Point {
  public static Point origin = new Point(); // static variable like System.out
  private int x, y; // instance variables 
  public int getX() { return this.x; } // accessor
  public Point() {
    this(0, 0); // calls a peer constructor 
  }
  public Point(int x, int y) { 
    this.x = x; // here this is just pointing to the instance (object itself) 
    this.y = y;
  }
  public double distanceTo(Point other) { // formal parameters (arguments) 
    int dx = this.x - other.x; // local variable 
    int dy = this.y - other.y;
    return Math.sqrt(Math.pow(dx, 2) + Math.pow(dy, 2)); 
  }
  public static void main(String[] args) {
    Point a = new Point(1, 1); // local variable a 
    System.out.println(a.distanceTo(Point.origin)); // expected 1.4142... (sqrt 2)
    System.out.println(Point.origin.distanceTo(a)); // same value expected 
  }
}

Exercises: 

  (a) design a class Circle; Circle objects report area and whether they overlap another Circle or not 
  (b) design a class Line; they just tell us their length (maybe find out if they intersect, etc.) 
  (c) design a class Triangle; Triangle objects report their areas (use Heron's formula for area) 

So design can be hierarchical (Circle has Point inside, Triangle has Line but starts from Points etc.) 

--

import java.util.Scanner; 

public class Example {
  public static void main(String[] args) {
    Scanner evening; // local variable 
    int sum = 0; // local variable must be initialized by the programmer
    evening = new Scanner(System.in); 
    System.out.print("type> "); 
    String line = evening.nextLine(); 
    while ( ! line.equals("bye") ) { // user agreement: type "bye" or number 
      // not (line reads "bye" but doesn't have to be the exact same object)
      // System.out.println( line );
      int number = Integer.parseInt( line ); // parses the input into a number 
      sum = sum + number; 
      System.out.print("The sum becomes: " + sum + "\ntype> "); 
      line = evening.nextLine();
    }
    System.out.println("See you later."); 
  }
}

--

Nested loops: next time and also arrays and ArrayLists. 

--

public class What {
  
  int value;

  What next;
  
  public What(int value, What next) {
    this.value = value;
    this.next = next;
  }
  
  public String toString() { return this.value + " " + this.next; }
  
  public static void main(String[] args) {
    What what = null;
    System.out.println(what); // 10.
    what = new What(3, what);
    System.out.println(what); // 11.
    what = new What(1, what);
    System.out.println(what); // 12.
    what.next = new What(5, new What(4, what.next));
    System.out.println(what); // 13.
    what = new What(2, what);
    System.out.println(what); // 14.
  }
}

--

Welcome to DrJava.  Working directory is C:\Users\dgerman\Desktop\whatever
> run What
null
3 null
1 3 null
1 5 4 3 null
2 1 5 4 3 null


--