数据类型拓展
package com.company;
public class Main {
? ? public static void main(String[] args) {
? ? ? ? System.out.println("int============================");
? ? ? ?int i=10;
? ? ? ?int i2=010;//八進制的10
? ? ? ?int i3=0x10;//十六進制10
? ? ? ?System.out.println(i);
? ? ? ?System.out.println(i2);
? ? ? ?System.out.println(i3);
? ? ? ?int i4=0x11;
? ? ? ?System.out.println(i4);
? ? ? ?System.out.println("float=============================");
? ? ? ? //接近但不等于,盡量不要用浮點數(shù)比較;so 銀行業(yè)務用BigDicemal
? ? ? ? float f=0.1f;
? ? ? ? double d=1.0/10;
? ? ? ? System.out.println(f);
? ? ? ? System.out.println(d);
? ? ? ? System.out.println(f==d);
? ? ? ? float f1=1111111111112342442f;
? ? ? ? float f2=1111111111112342442f+1;
? ? ? ? System.out.println("====f1==f2========================");
? ? ? ? System.out.println(f1==f2);
? ? ? ? System.out.println("char=========================");
? ? ? ? char c1='a';
? ? ? ? char c2='中';
? ? ? ? System.out.println(c1);
? ? ? ? System.out.println((int)c1);
? ? ? ? System.out.println(c2);
? ? ? ? System.out.println((int)c2);
? ? ? ? //unicode
? ? ? ? char c3='\u0061';
? ? ? ? System.out.println(c3);
? ? ? ? System.out.println("轉(zhuǎn)義字符========================");
? ? ? ? //t
? ? ? ? System.out.println("a\tb");
? ? ? ? //\n
? ? ? ? System.out.println("a\nb");
? ? }
}
int============================
10
8
16
17
float=============================
0.1
0.1
false
====f1==f2========================
true
char=========================
a
97
中
20013
a
轉(zhuǎn)義字符========================
a?? ?b
a
b
加qq群422464063學習
總結(jié)
- 上一篇: C语言 sizeof 函数 - C语言零
- 下一篇: H264/ACC数据使用librtmp推