public class Variable { static int allClicks = 0; // class variable String STR = "Hello World"; // instance variables public void Method () { int I = 0; // local variable } }
public class the Test { public void pupAge () { int Age = 0 ; Age = Age +. 7 ; System.out.println ( "dog's age:" + Age); } public static void main (String [] args) { the Test Test = new new the Test (); test.pupAge (); } }
public class the Test { public void pupAge () { int Age; Age = Age +. 7 ; System.out.println ( "dog's age:" + Age); } public static void main (String [] args) { the Test Test = new new the Test (); test.pupAge (); } }
Import the java.io. * ; public class the Employee { // this sub-class instance variables visible public String name; // private variable, only such visible Private Double the salary; // the name assigned to the constructor public the Employee ( empName String) { name = empName; } // set value of salary public void setSalary ( Double empSal) { salary = empSal; } // print information public void with Printemp () { System.out.println ("名字 : " + name ); System.out.println("薪水 : " + salary); } public static void main(String[] args){ Employee empOne = new Employee("RUNOOB"); empOne.setSalary(1000); empOne.printEmp(); } }
Import java.io. * ; public class the Employee { // salary is static private variable Private static Double salary; // the DEPARTMENT is a constant public static Final String the DEPARTMENT = "developers" ; public static void main (String [] args ) { the salary = 10000 ; System.out.println (the DEPARTMENT + "average wage:" + the salary); } }