public class Tom {private float weight;private static String name;public void setWeight(float weight) {this.weight = weight;}private void out() {System.out.println(name + "体重:" + weight + "斤");}public static void main(String[] args) {Tom.name = "kitty";Tom cat = new Tom();cat.setWeight(10);cat.out();}}
查看答案
public class Test {public static void main(String[] args){int i=3;switch(i){default: System.out.print("not found");case 0: System.out.print("0");break;case 1:System.out.print("1");case 2:System.out.print("2");}}}
public class Father {String name, address, tel;int age;public Father(String name, int age) {this.name = name;this.age = age;}void out() {System.out.print("姓名:" + name);System.out.print("年龄:" + age);}void outOther() {System.out.print("家庭住址:" + address);System.out.print("电话:" + tel);}}class Son extends Father {String school;public Son(String name, int age) {super(name, age);}void out() {super.out();super.outOther();System.out.println("学校:" + school);}public static void main(String args[]) {Son son = new Son("Tom",22);son.address = "武清区";son.school = "天狮学院";son.tel = "123456";son.out();}}
public class MyClass {int a[] = { 1, 2, 3, 4, 5,6 };void out() {for (int j = 0; j < a.length; j++)System.out.print(a[j] + "");}public static void main(String[] args) {MyClass my = new MyClass();my.out();}}
public class Test{public static void main(String[] args) {int i,s=0;int a[]= {10,20,30,40,50,60,70,80,90};for(i=0;i