class A { int a,b,c; int zhouchang() { return a+b+c; } double area() { double p=1.0*(a+b+c)/2; return Math.sqrt(p*(p-a)*(p-b)*(p-c)); } } public class testa { public static void main(String[] args) { A t=new A(); //创建了一个新的对象 t.a=3; //新参数对象class A中的啊,a,b,c t.b=4; t.c=5; System.out.printf("%d %f\n",t.zhouchang(),t.area()); //这不能用println(用+号连接时可以用),printf格式化输出(%d) } } public class testb { public static void main(String[] args) { int A = 597; int a = A % 10; int b = A / 10 % 10; int c = A / 100; System.out.printf("个位数是%d", a); //注意这里的printf,根据形式别误用成println System.out.printf("十位数是%d", b); System.out.printf("百位数是%d", c); } }