Assignment and comparison of

[Generally the first statement in the operation, where you can re-create the point to declare]

. 1  Package DemoArea6.copy;
 2  
. 3  Import org.omg.PortableServer.POAPackage.ServantAlreadyActive;
 . 4  
. 5  public  class Area6 {
 . 6      Private  int A;
 . 7      Private  int B;
 . 8      Private String Color;
 . 9      public  static  int NUM = 0 ;
 10      
. 11      
12 is      public Area6 ( int a, int B, String COL) {
 13 is          // definition has reference constructor 
14          a = a;
 15         = B B;
 16          Color = COL;
 . 17          NUM ++; // when a constructor is called NUM ++
 18 is          // record the number of objects depending on the example sentence order,
 19          // if two consecutive instances of objects, at this time, num is the 2, occurs when the separated 1,2 
20 is      }
 21 is      
22 is      int showarea () {
 23 is          return a * B;
 24      }
 25      String showColor () {
 26 is          return Color;
 27      }
 28      public  static  void COUNT () {
 29          // statement count is a static method 
30          
31         System.out.println ( "visited" + num + "views" );
 32          
33 is      }
 34 }
. 1  Package DemoArea6.copy;
 2  
. 3  public  class Mainarea6 {
 . 4  
. 5      public  static  void main (String [] args) {
 . 6          // the TODO Auto-Generated Method Stub 
. 7           Area6 A1, A2; // declare two reference variables 
. 8          
. 9           = A1 new new Area6 (3,12, "hS"); // create an object and point 
10           A2 = new new Area6 (3,6, "the LS" );
 . 11          
12 is          System.out.println ( "A1" + a1.showarea ());
 13 is          System.out.println ( "A1" +a1.showcolor ());
 14          a1.count (); // a call object instance, may be
 15          
16          // AREA5 new new AREA5 A2 = (3,6, "of the LS"); // second call 
17          System.out.println ( "A2" + a2.showarea ());
 18 is          System.out.println ( "A2" + a2.showcolor ());
 . 19          a2.count ();
 20 is          
21 is          
22 is      }
 23 is  
24 }

 

Guess you like

Origin www.cnblogs.com/dede-6/p/11899813.html