java练习

class A

{

	float a;

	static float b;

	void setA(float a)

	{

		this.a=a;

	}

	void setB(float b)

	{

		this.b=b;

	}

	float getA()

	{

		return a;

	}

	float getB()

	{

		return b;

	}

	void inputA()

	{

		System.out.println(a);

	}

	static void inputB()

	{

		System.out.println(b);

	}

}

public class Example

{

	public static void main(String args[])

	{

		A.b=100;

		A.inputB();

		A cat=new A();

		A dog=new A();

		cat.setA(200);

		cat.setB(400);

		dog.setA(150);

		dog.setB(300);

		cat.inputA();

		cat.inputB();

		dog.inputA();

		dog.inputB();

	}

}


你可能感兴趣的:(java)