Skip to content

Commit 5a0471d

Browse files
author
cicadasmile
committed
Java基础篇(01):基本数据类型,核心点整理
1 parent b470bd3 commit 5a0471d

12 files changed

Lines changed: 143 additions & 1 deletion

File tree

‎README.md‎

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
1-
# 参考文章
1+
## 参考文章
2+
3+
### JavaSE基础篇
4+
5+
[Java基础篇(01):基本数据类型,核心点整理](https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247484444&idx=2&sn=c5590ea2d71a0a358d2f9cd96c3c2b19&chksm=fdf450a4ca83d9b2383032c1aa354a59a0ca6d52981f2a58d6d3142bde7ed1605b4fcde3b4d9&token=1530600379&lang=zh_CN#rd)<br/>
6+
7+
### JavaEE基础
28

39
[JavaEE基础(01):Servlet实现方式,生命周期执行过程](https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247484304&idx=1&sn=dd6b6852e35031dd07f70d441f3ddc85&chksm=fdf45728ca83de3e158597030cf46b1677eccf533f9e1412690cd64b0ec0cce544711ceabddb&token=1248678182&lang=zh_CN#rd)<br/>
410
[JavaEE基础(02):Servlet核心API用法详解](https://mp.weixin.qq.com/s?__biz=MzU4Njg0MzYwNw==&mid=2247484309&idx=1&sn=fc8237aef2f246f85b978561f4b37e1e&chksm=fdf4572dca83de3b8affdf4a9a8c8b3c18e4c5203c3e663e0bfaeb53788d3e2d26fa829bb8c6&token=1248678182&lang=zh_CN#rd)<br/>
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<parent>
6+
<artifactId>java-se-base-parent</artifactId>
7+
<groupId>com.java.se.parent</groupId>
8+
<version>1.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
<groupId>com.data.type</groupId>
12+
<artifactId>model-data-type</artifactId>
13+
14+
15+
</project>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package com.data.type;
2+
3+
public class HelloDataType {
4+
public static void main(String[] args) {
5+
System.out.println("基础数据类型模块");
6+
}
7+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.data.type.block01base;
2+
3+
public class IntType01 {
4+
public static void main(String[] args) {
5+
System.out.println("进制位数:"+Integer.SIZE);
6+
System.out.println("最小值:"+Integer.MIN_VALUE);
7+
System.out.println("最大值:"+Integer.MAX_VALUE);
8+
System.out.println("进制位数:"+Double.SIZE);
9+
System.out.println("最小值:"+Double.MIN_VALUE);
10+
System.out.println("最大值:"+Double.MAX_VALUE);
11+
}
12+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package com.data.type.block01base;
2+
3+
4+
public class IntType02 {
5+
public static void main(String[] args) {
6+
// 自动转换
7+
int i = 112 ;
8+
long j = i ;
9+
System.out.println(j);
10+
// 强制转换
11+
double d = 13.14 ;
12+
int f = (int)d;
13+
System.out.println(f);
14+
// 类型提升
15+
long r = i * j ;
16+
System.out.println(r);
17+
}
18+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package com.data.type.block01base;
2+
3+
public class IntType03 {
4+
public static void main(String[] args) {
5+
Integer int1 = null ;
6+
Double dou1 = 13.14 ;
7+
Long lon1 = 123L ;
8+
}
9+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package com.data.type.block01base;
2+
3+
public class IntType04 {
4+
public static void main(String[] args) {
5+
char cha1 = '知';
6+
System.out.println(cha1);
7+
}
8+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
package com.data.type.block01base;
2+
3+
public class IntType05 {
4+
public static void main(String[] args) {
5+
short s1 = 1 ;
6+
// s1 = s1 + 1 ; // 变异错误:s1自动向int类型转换
7+
s1 += 1 ;
8+
System.out.println(s1);
9+
}
10+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package com.data.type.block01base;
2+
3+
public class IntType06 {
4+
public static void main(String[] args) {
5+
// 存在精度损失问题:0.30000000000000004
6+
System.out.println(3*0.1);
7+
// true
8+
System.out.println(0.3 == 0.3);
9+
// false
10+
System.out.println(3*0.1 == 0.3);
11+
}
12+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.data.type.block01base;
2+
3+
public class IntType07 {
4+
public static void main(String[] args) {
5+
// float 声明
6+
float f1 = 12.3f ;
7+
// double 声明
8+
double d1 = 13.4 ;
9+
// 向下转型,需要强制转换
10+
float f2 = (float) d1 ;
11+
System.out.println("f1="+f1+";d1="+d1+";f2="+f2);
12+
}
13+
}

0 commit comments

Comments
 (0)