package com.Abstract;
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Shape retangle=new Retangle();
retangle.Lounds();
retangle.Squarle();
Shape circle= new Circle();
circle.Squarle();
circle.Lounds();
}
}
public class main {
public static void main(String[] args) {
// TODO Auto-generated method stub
Shape retangle=new Retangle();
retangle.Lounds();
retangle.Squarle();
Shape circle= new Circle();
circle.Squarle();
circle.Lounds();
}
}
2017-07-21
public class HelloWorld {
// 定义静态变量,保存班级名称
String className = "JAVA开发一班";
public static void main(String[] args) {
HelloWorld hellow=new HelloWorld();
// 访问静态变量,输出班级名称
System.out.println(hellow.className);
}
}
// 定义静态变量,保存班级名称
String className = "JAVA开发一班";
public static void main(String[] args) {
HelloWorld hellow=new HelloWorld();
// 访问静态变量,输出班级名称
System.out.println(hellow.className);
}
}
2017-07-21
static int score2 = 92;
// 定义静态方法sum,计算成绩总分,并返回总分
public static int sum() {
int sum=score1+score2;
return sum;
}
public static void main(String[] args) {
// 调用静态方法sum并接收返回值
int allScore = sum();
System.out.println("总分:" + allScore);
}
// 定义静态方法sum,计算成绩总分,并返回总分
public static int sum() {
int sum=score1+score2;
return sum;
}
public static void main(String[] args) {
// 调用静态方法sum并接收返回值
int allScore = sum();
System.out.println("总分:" + allScore);
}
2017-07-21
写错了,如果成员变量名相同,name默认为inner的变量,如果想要调用outer的name,则需使用OuterClassName.this.name
2017-07-21
已采纳回答 / 羽劭icon
首先是面向对象;public class Animal{public int age;public void show(){int a;System.out.println("动物的年龄是:"+age);}}这里的Animal是类,age是属性,a是变量,show是方法
2017-07-20