Files
  • Main.java
  • Main$Num.class
  • Main.class
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
public class Main{
   public static void main (String[] args){
      Num n1 = new Num (56);
      Num n2 = new Num (57);
      Integer i1 = new Integer (23);
      Integer i2 = new Integer (24);
      System.out.println ("n1: " + n1);
      System.out.println ("n2: " + n2);
      System.out.println ("i1: " + i1);
      System.out.println ("i2: " + i2);
      System.out.println ();
      n1 = n2;
      i1 = i2;
      System.out.println ("n1: " + n1);
      System.out.println ("n2: " + n2);
      System.out.println ("i1: " + i1);
      System.out.println ("i2: " + i2);
      System.out.println ();
      n1.setValue(n1.getValue()+1);
      i1++;
      System.out.println ("n1: " + n1);
      System.out.println ("n2: " + n2);
      System.out.println ("i1: " + i1);
      System.out.println ("i2: " + i2);
      System.out.println ();
   }
   public static class Num{
   private int value;

   public Num (int update){
      value = update;
   }
   public int getValue (){
      return value;
   }
   public void setValue (int update){
      value = update;
   }
   public String toString (){
      return value + "";
   }
 }
}