package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
byte b1 = 12;
System.out.println(b1);
// 声明long型变量,必须以“l”或“L”结尾
//通常定义整型变量时候,使用int
long l1 = 12345676l;
System.out.println(l1);
}
}
浮点型表示带小数点的数值;float虽然只占用四个字节,但是它的存储内容比long还大
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
byte b1 = 12;
System.out.println(b1);
// 声明long型变量,必须以“l”或“L”结尾
//通常定义整型变量时候,使用int
long l1 = 12345676l;
System.out.println(l1);
double d1 = 123.3;
System.out.println(d1);
//定义float变量时,变量要以“f"或”F“结尾
float f1 = 12.3f;
System.out.println(f1);
// 通常定义浮点型变量,我们通常使用double
}
}
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
byte b1 = 12;
System.out.println(b1);
// 声明long型变量,必须以“l”或“L”结尾
//通常定义整型变量时候,使用int
long l1 = 12345676l;
System.out.println(l1);
double d1 = 123.3;
System.out.println(d1);
//定义float变量时,变量要以“f"或”F“结尾
float f1 = 12.3f;
System.out.println(f1);
// 通常定义浮点型变量,我们通常使用double
//字符型 :char(1字符=2字符)
//定义char型变量,通常使用一对‘’,内部只能写一个字符
char c1 = '啊';
//编译不通过
//c1 = 'ab';
System.out.println(c1);
//表示方式:1.声明一个字符 2.转义字符 3.使用Unicode值来表示字符型常量
char c4 = 'n'; //换行符号
c4 = 't'; //制表符
System.out.println(c4);
char c5 = 'u0023';
System.out.println(c5);
}
}
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
System.out.println("hello word 你好");
}
}
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
//布尔型:Boolean 只能取两个值true false
//使用范围 在条件判断,循环结构中使用
boolean bb1 = true;
System.out.println(bb1);
boolean isMarried = true;
if (isMarried) {
System.out.println("不能参加n单身"聚会"了!n很遗憾");
} else {
System.out.println("找一个女朋友");
}
}
}
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
double d1 = 12.4;
//精度损失举例1
int i1 = (int)d1; //截断操作
System.out.println(i1);
//没有精度损失
long l1 = 123;
short s2 = (short)l1;
System.out.println(s2);
//精度损失举例2
int i2 = 124;
byte b = (byte)i2;
System.out.println(b);
}
}
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
//1.编码情况:
long l = 1234;
System.out.println(l);
//编译失败:过大的整数
//long l1 =122345678654321;
long l1 = 234567898765432l;
/
package com.company;
public class Main {
public static void main(String[] args) {
// write your code here
String s1 = "heoll word";
System.out.println("s1");
//************************************88
int number = 110;
String numberStr = "学号:";
String info = numberStr + number; // + 连接运算
boolean b1 = true;
System.out.println(info);
//练习1
char c = 'a'; //a 97 A 65
int num = 10;
String str = "hello";
System.out.println(c + num + str);
System.out.println(c + str + num);
System.out.println(c + (num + str));
System.out.println((c + num) + str);
System.out.println(str + num + c);
//107hello
//ahello10
//a10hello
//107hello
//hello10a
//练习2
//* *
System.out.println("* *");
System.out.println('*' + 't' + '*');
System.out.println('*' + "t" + '*');
System.out.println('*' + 't' + "*");
System.out.println('*' + ('t' + "*"));
//* *
//93
//* *
//51*
//* *
}
}



