Java中整数和浮点文字之间的区别是什么?
整数文字表示固定的整数值,例如900、12、400,-222等(在整数范围内)。
浮点文字表示分数值,即带有十进制值的数字,例如25.53、45.66、58.66等。在编写这些文字时,我们应使用符号f或F作为25.53。
示例
public class StringExample {
public static void main(String args[]){
int num1 = 100;
float num2 = 30.0f;
System.out.println("Value of integer:"+num1);
System.out.println("Value of integer:"+num2);
}
}输出结果
Value of integer:100 Value of integer:30.0
热门推荐
10 儿子立冬祝福语简短独特
11 对当兵的祝福语简短
12 侄儿高考试祝福语简短
13 伴郎红包祝福语朋友简短
14 媳妇生日简短祝福语朋友
15 公司年会祝福语简短最好
16 元旦感恩祝福语简短大全
17 红包祝福语简短10字
18 周六早晨祝福语简短