class point1
{
int x,y;
}
class carry
{
int p1(point1 l)
{l.x=l.x+l.y;
return l.x;
}
int p2(point1 l)
{l.y=5*l.y;
return l.y;
}
}
class usep
{
public static void main(String[] args)
{
carry s=new carry();
point1 q=new point1();
q.x=3;
q.y=5;
System.out.println("对象q实例变量X的值:"+s.p1(q));
System.out.println("对象q实例变量Y的值:"+s.p2(q));
System.out.println("再次调用对象q实例变量X的值:"+s.p1(q));
}
}
{
int x,y;
}
class carry
{
int p1(point1 l)
{l.x=l.x+l.y;
return l.x;
}
int p2(point1 l)
{l.y=5*l.y;
return l.y;
}
}
class usep
{
public static void main(String[] args)
{
carry s=new carry();
point1 q=new point1();
q.x=3;
q.y=5;
System.out.println("对象q实例变量X的值:"+s.p1(q));
System.out.println("对象q实例变量Y的值:"+s.p2(q));
System.out.println("再次调用对象q实例变量X的值:"+s.p1(q));
}
}
完全不象在写JAVA,象在写C,晕倒.
这个应该是初学的时候看类内的实例变量及参数传递的例子。
不能以程序结构这种角度来看吧。