变量注意事项

变量注意事项,第1张

变量注意事项

名字不能重复
变量未赋值,不能使用
long 类型的变量定义的时候,为了防止整数过大。后面加L
float类型的变量定义的时候,为了防止类型不兼容,后面加F
否则出现以下结果:
text1.java:15: 错误: 不兼容的类型: 从double转换到float可能会有损失
float f=12.14;
text1.java:12: 错误: 整数太大
long l=10000000000000;

public class text1 {
	public static void main(String[] args) {
		int a=10;
		System.out.println(a);
		
		a=20;
		System.out.println(a);
		
		boolean bb=true;
		System.out.println(bb);
		
		long l=10000000000000L;
		System.out.println(l);
		
		float f=12.14F;
		System.out.println(f);
	}
}

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5708239.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-17
下一篇 2022-12-17

发表评论

登录后才能评论

评论列表(0条)

保存