Write a program that reads two integers. 

The program then calculates the largest. 

Can't use if, for, while, do, ? :

--

class Eleven {
  public static void main(String[] args) {

    int number = Integer.parseInt( args[0] );
    
    System.out.println( Math.sqrt( number ) );
    
  }
}

--

import java.util.*;

class Eleven {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in); 
    System.out.print("Type a number: "); 
    String line = in.nextLine(); 

    int number; 
    number = Integer.parseInt( line ); 
    System.out.println( Math.sqrt( number ) );
  }
}

--

import java.util.*;

class Eleven {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in); 
    System.out.print("Type a number: "); 
    String line = in.nextLine(); 

    try { 
      int number; 
      number = Integer.parseInt( line ); 
      System.out.println( Math.sqrt( number ) );
    } catch (Exception e) {
      System.out.println( "Darn." );  
    }

  }
}

--

import java.util.*;

class Eleven {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in); 
    System.out.print("Type a number: "); 
    String line = in.nextLine(); 
    while (true) {
      try { 
        int number; 
        number = Integer.parseInt( line ); 
        System.out.println( Math.sqrt( number ) );
        break; 
      } catch (Exception e) {
        // System.out.println( "Darn." );  
        System.out.println(line + " is not a number, blah blah...");
        System.out.print("Type another number: "); 
        line = in.nextLine(); 
      }
    }
  }
}

--

import java.util.Scanner; 

public class Six {
  public static void main(String[] args) {
    while (true) { 
      System.out.print("Please enter an integer: "); 
      Scanner s = new Scanner(System.in); 
      String n = s.nextLine();
      try {
        int number = Integer.parseInt(n); 
        System.out.println("You have entered " + n + " with square root " + Math.sqrt(number));
        s.close();
        break;
      } catch (Exception e) {
        System.out.println("Sorry, " + n + " not an integer."); 
      }
    }
  }
}

--

import java.awt.event.*; 
import javax.swing.*;

public class Three implements ActionListener {
  public static void main(String[] args) {
    Three three = new Three();
    Timer timer = new Timer(1000, three); 
    timer.start(); 
  }
  int count = 0; 
  public void actionPerformed(ActionEvent e) {
    this.count += 1; 
    System.out.println( this.count ); 
  }
}

--

import java.awt.event.*; 
import javax.swing.*;

public class Three implements ActionListener {
  public static void main(String[] args) {
    Three three = new Three();
    Timer timer = new Timer(1000, three); 
    timer.start(); 
  }
  int count = 0; 
  public void actionPerformed(ActionEvent e) {
    this.count += 1; 
    System.out.println( this.count ); 
  }
}

--

import java.awt.event.*; 
import javax.swing.*;

public class Three implements ActionListener {
  public static void main(String[] args) {
    JFrame a = new JFrame(); 
    a.setVisible(true); 
    System.out.println(" hjgfjhfgfjshg "); 
    Three three = new Three();
    Timer timer = new Timer(1000, three); 
    timer.start(); 
  }
  int count = 0; 
  public void actionPerformed(ActionEvent e) {
    this.count += 1; 
    System.out.println( this.count ); 
  }
}

--

import javax.swing.*; 
import java.awt.*; 
import java.awt.event.*; 

public class Scribble extends JComponent implements MouseMotionListener {
  public void mouseMoved(MouseEvent e) { 
    System.out.println( "Mouse is being moved... "); 
  }
  public void mouseDragged(MouseEvent e) { 
    int x = e.getX();
    int y = e.getY();
    Graphics g = this.getGraphics(); 
    g.drawOval(x, y, 20, 20);
  }
  int i = 0; 
  public void paintComponent(Graphics g) {
    System.out.println( i++ ); 
  }
  public static void main(String[] args) {
    Scribble a = new Scribble();  
    JFrame b = new JFrame(); 
    b.addMouseMotionListener( a ); 
    b.add(a); 
    b.setVisible(true); 
    b.setSize(500, 500); 
  }
}

Minimize then restore: why do we lose it? 

How can we keep it? 

--