day02数据类型

Typora  添加代码  ~~~ java

public class HelloWorld {
public static void main(String[] args) {
//输出一个 Hello World!
//单行注释
System.out.println("Hello World");
//八大基本数据类型
//四种整数

int num1=10; //最常用
byte num2=20;
short num3=30;
long num4=30L; //一般在数字后面加L
//小数:浮点float
float num5=40.1F;
double num6=3.141592665413516854653165;
char name='q';//字符
String name1="qwer"; //字符串
boolean flag=true;//布尔变量 只有是非
boolean flag1=false;
//整数拓展 进制 二进制0b 八进制0 十进制 十六进制0x
int i=10;
int i2=010;//八进制
int i3=0x10;//十六进制 0-9 A-F
System.out.println(i);
System.out.println(i2);
System.out.println(i3);
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
System.out.println("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~");
//浮点数拓展 银行业务怎么表示?钱
//BigDecimal 数学工具类
//float 有限的 离散 舍入误差 大约 接近但不等于
//double
//最好完全避免使用浮点数进行比较
//最好完全避免使用浮点数进行比较
//最好完全避免使用浮点数进行比较

float f=0.1f;
double d=1.0/10;
System.out.println(f==d);
System.out.println(f);
System.out.println(d);
float d1=21321321321321f;
float d2=d1+1;
System.out.println(d1==d2);
//字符拓展
char c1='中';
char c2='a';
System.out.println(c1);
System.out.println((int)c1);
System.out.println(c2);
System.out.println((int)c2);
//所有字符本质还是数字
//编码 Unicode 表(97=a 65=A) 2字节 65536 Excel 2的十六次方=65536
//U0000-UFFFF
char c3='\u0061';
System.out.println(c3);
//转义字符
// \t 制表符
// \n换行
//..........
System.out.println("Hello\tWorld");
String sa=new String("Hello World");
String sb=new String("Hello World");
System.out.println(sa==sb);
String sc="Hello World";
String sd="Hello World";
System.out.println(sc==sd);
//布尔值拓展
boolean flag=true;
if (flag==true){ }//新手
if (flag){}//老手
//Less Is More! 代码要精简易读!
}
}
// 多行注释 /* */
// JavaDoc:文档注释 /** */
/**
* @Description Hello World
* @Author zhang
*/
//有趣的代码注释
// _ooOoo_
// o8888888o
// 88" . "88
// (| -_- |)
// O\ = /O
// ____/`---'\____
// . ' \\| |// `.
// / \\||| : |||// \
// / _||||| -:- |||||- \
// | | \\\ - /// | |
// | \_| ''\---/'' | |
// \ .-\__ `-` ___/-. /
// ___`. .' /--.--\ `. . __
// ."" '< `.___\_<|>_/___.' >'"".
// | | : `- \`.;`\ _ /`;.`/ - ` : | |
// \ \ `-. \_ __\ /__ _/ .-` / /
// ======`-.____`-.___\_____/___.-`____.-'======
// `=---='
//
// .............................................
// 佛祖保佑 永无BUG


posted @ 2020-04-16 10:12  凉薄之人v  阅读(109)  评论(0)    收藏  举报