:)class Person
{
String name;
int age;
{
cry();
} Person(String name)
{
this.name = name; //成员变量 = 局部变量;
}
Person(String name,int age)
{
this.name = name;
this.age = age;
}
void show()
{
System.out.println("name = "+name+"..."+"age = "+age);
}
void cry()
{
System.out.println("cry...");
}
}
public class Demo
{
public static void main(String[] args)
{
Person p = new Person("lisi"); //类 对象 = new 类();
Person p1 = new Person("wangwu",18);
p.show();
p1.show();
}
}
class Person
{
String name;
int age;
{
cry();
}
Person(String name)
{
this.name = name; //成员变量 = 局部变量;
}
Person(String name,int age)
{
this.name = name;
this.age = age;
}
void show()
{
System.out.println("name = "+name+"..."+"age = "+age);
}
void cry()
{
System.out.println("cry...");
}
}
public class Demo
{
public static void main(String[] args)
{
Person p = new Person("lisi"); //类 对象 = new 类();
Person p1 = new Person("wangwu",18);
p.show();
p1.show();
}
}
红色标示的代表什么意思啊?为什么在程序能够先执行呢?谢谢啦!! |