Java_各种数据类型的运算

class JavaDemo3
{
	public static void main(String args[])
	{
		int i = 10;
		int j = 3;
		float f = 3.0f;//必须加f或F
		double d = 3.0;

		++f;
		System.out.println("i / f = " + i/f);
		System.out.println("f = " + f);

		d++;
		System.out.println("i / d = " + i/d);
		System.out.println("d = " + d);

		float k = f += d;
		System.out.println("k = " + k);

		int p = i *= j;
		System.out.println("p = " + p);

		int m = i /= j;
		System.out.println("m = " + m);
	}
}

/*
	---------- java ----------
i / f = 2.5
f = 4.0
i / d = 2.5
d = 4.0
k = 8.0
p = 30
m = 10

*/

你可能感兴趣的:(Java_各种数据类型的运算)