Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - JAVA declared an integer variable.
JAVA declared an integer variable.
Int a = 1 can be used directly; You can also use the internally provided Integer class, because in Java, everything is the class Integer Myint = New Integer (10);

For these two declaration methods, if they are not initialized and are local variables, their values are uncertain; If they are global variables, they default to 0. Open level test {private int num//( 1) declares integer variables! Public int getnum ()//(2) declares the method to get the value of this variable. {Return number; }

The Public void setNum(int num) //(2) declaration method designs the value of this variable {this.num = num}

public static void main(String[]args){ Test TT = new Test():TT . setnum( 123); //(3) Call the above two methods at the program access point (main). int result = TT . getnum(); System.out.println (result); //(4) Output the result of calling the method at an appropriate location.