标签:
classDog{
String name;
int age;
String color;
void jump(){
System.out.println("jump");
}
}
classTestDog{
publicstaticvoid main(String args[]){
Dog d =newDog();
d.name ="旺财";
d.age =2;
d.color ="黑色";
d.jump();
System.out.println("名字是"+d.name);
}
}
classDog{
String name;
int age;
String color;
void jump(){
System.out.println("jump");
}
}
classTestDog{
publicstaticvoid main(String args[]){
Dog d1 =newDog();
Dog d2 =newDog();
d1.name ="旺财";
d2.name ="四喜";
d1.jump();
d2.jump();
System.out.println("名字是"+d1.name);
System.out.println("名字是"+d2.name);
}
}
class A{
void funA(){
System.out.println("没有参数的funA函数");
}
void funA(int i){
System.out.println("拥有一个整形参数的funA函数");
}
}
classTestA{
publicstaticvoid main(String args[]){
A a =new A();
a.funA();
a.funA(10);
}
}
classPerson{
Person(){
}
Person(String n,int a){
name = n;
age = a;
}
String name;
int age;
}
classTestA{
publicstaticvoid main(String args[]){
Person person1 =newPerson("zhagnsan",10);
Person person2 =newPerson("lisi",20);
System.out.println("person1的name是:"+person1.name+",age是"+person1.age);
System.out.println("person2的name是:"+person2.name+",age是"+person2.age);
}
}
标签:
原文地址:http://www.cnblogs.com/arroneve/p/5815427.html