输出(x,y)的坐标

public class Point_Test {

	public static void main(String[] args)
	{
		// TODO Auto-generated method stub
		point point = new point();
		point.showpoint();//调用x,y的初始值
		point.setX(3);//为x赋值
		point.setY(7);//为y赋值
		point.showpoint();
	}
}
public class point 
{
	int x = 0, y = 0;
	void setX(int x)
	{
		this.x = x;
	}
	void setY(int y)
	{
		this.y = y;
	}
	void showpoint()
	{
		System.out.println("当前坐标:("+x+","+y+")");
	}
}

你可能感兴趣的:(java基础)