Skip to content

Commit a8263f9

Browse files
committed
feat: add java-base
1 parent 2ca1c77 commit a8263f9

10 files changed

Lines changed: 354 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
3+
<parent>
4+
<artifactId>core-java-modules</artifactId>
5+
<groupId>com.wdbyte.core-java-modules</groupId>
6+
<version>1.0.0-SNAPSHOT</version>
7+
</parent>
8+
<modelVersion>4.0.0</modelVersion>
9+
<artifactId>core-java-base</artifactId>
10+
<name>Archetype - core-java-base</name>
11+
<url>http://maven.apache.org</url>
12+
</project>
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
package com.wdbyte;
2+
3+
import java.util.ArrayList;
4+
import java.util.Arrays;
5+
import java.util.List;
6+
7+
/**
8+
* @author niulang
9+
* @date 2023/03/23
10+
*/
11+
public class JavaArray {
12+
13+
public static void main(String[] args) {
14+
15+
// 数组定义
16+
String[] aaa = new String[11];
17+
System.out.println(aaa.length);
18+
// 数组访问
19+
int[] arr = {1, 2, 3};
20+
System.out.println(arr.toString()); // 数组地址
21+
arr[0] = 10;
22+
System.out.println(arr[0]);
23+
24+
for (int a : arr) {
25+
System.out.println(a);
26+
}
27+
for (int i = 0; i < arr.length; i++) {
28+
System.out.println(arr[i]);
29+
}
30+
31+
// copy
32+
String[] strArr = {"hello", "world", "!"};
33+
String[] strArrByClone = strArr.clone();
34+
System.out.println(String.join(" ", strArrByClone));
35+
// 输出:hello world !
36+
String[] strAyyByCopy = new String[5];
37+
System.arraycopy(strArr,1,strAyyByCopy,3,2);
38+
for (String s : strAyyByCopy) {
39+
System.out.println(s);
40+
}
41+
String[] newArr = Arrays.copyOfRange(strArr, 0, 2);
42+
System.out.println(Arrays.toString(newArr));
43+
// 输出:null
44+
//null
45+
//null
46+
//world
47+
//!
48+
49+
Person[][] personArr = new Person[2][2];
50+
personArr[0][0] = new Person("www");
51+
personArr[1][1] = new Person("wdbyte.com");
52+
Person[][] personArrByClone = personArr.clone();
53+
personArrByClone[0][0] = new Person("https://www");
54+
System.out.println(personArr[0][0].name);
55+
System.out.println(personArrByClone[0][0].name);
56+
57+
int[] numArr = {1, 3, 5, 7, 9, 2, 4, 6, 8, 10};
58+
// 对数组进行排序
59+
Arrays.sort(numArr);
60+
// 将数组转换成字符串输出
61+
System.out.println(Arrays.toString(numArr));
62+
// 将数组转换成 List
63+
String[] strArray = new String[3];
64+
// 将数组的所有元素都赋为指定的值
65+
Arrays.fill(strArray,"byte");
66+
System.out.println(Arrays.toString(strArray));
67+
List<String> stringList = Arrays.asList("a","b","c");
68+
System.out.println(stringList);
69+
}
70+
static class Person{
71+
public String name;
72+
public Person(String name) {
73+
this.name = name;
74+
}
75+
}
76+
77+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
package com.wdbyte;
2+
3+
/**
4+
* @author niulang
5+
* @date 2023/03/25
6+
*/
7+
public class JavaArray3 {
8+
9+
public static void main(String[] args) {
10+
int[][] myArray1 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
11+
int[][] myArray2 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
12+
int[][] myArray3 = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
13+
int[][][] array3d = {myArray1, myArray2, myArray3};
14+
for (int i = 0; i < array3d.length; i++) {
15+
for (int j = 0; j < array3d[i].length; j++) {
16+
for (int k = 0; k < array3d[i][j].length; k++) {
17+
System.out.print(array3d[i][j][k] + " ");
18+
}
19+
System.out.println();
20+
}
21+
System.out.println("-----");
22+
}
23+
System.out.println(array3d[1][1][1]);
24+
}
25+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
package com.wdbyte;
2+
3+
/**
4+
* @author niulang
5+
* @date 2023/03/23
6+
*/
7+
public class JavaDataType {
8+
9+
public static void main(String[] args) {
10+
boolean result = true;
11+
char capitalC = 'C';
12+
byte b = 100;
13+
short s = 10000;
14+
int i = 100000;
15+
16+
// 10 进制的 26
17+
int decVal = 26;
18+
// 16 进制的 26
19+
int hexVal = 0x1a;
20+
// 2 进制的 26
21+
int binVal = 0b11010;
22+
System.out.println(decVal);
23+
System.out.println(hexVal);
24+
System.out.println(binVal);
25+
26+
long creditCardNumber = 1234_5678_9012_3456L;
27+
long socialSecurityNumber = 999_99_9999L;
28+
float pi = 3.14_15F;
29+
long hexBytes = 0xFF_EC_DE_5E;
30+
long hexWords = 0xCAFE_BABE;
31+
long maxLong = 0x7fff_ffff_ffff_ffffL;
32+
byte nybbles = 0b0010_0101;
33+
long bytes = 0b11010010_01101001_10010100_10010010;
34+
35+
}
36+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
package com.wdbyte;
2+
3+
/**
4+
* @author niulang
5+
* @date 2023/03/22
6+
*/
7+
public class JavaString {
8+
public static void main(String[] args) {
9+
//String str1 = "Hello world";
10+
//String str2 = "Hello world";
11+
//String str3 = new String("Hello world");
12+
//String str4 = new String("Hello world");
13+
//
14+
//System.out.println(str1 == str2);
15+
//System.out.println(str3 == str4);
16+
//System.out.println(str1 == str4);
17+
// 比较
18+
//String str1 = "abc";
19+
//String str2 = "abz";
20+
//System.out.println(str1.compareTo(str2));
21+
//System.out.println(str2.compareTo(str1));
22+
//// 输出:-23
23+
//// 输出:23
24+
//System.out.println("19999".compareTo("2"));
25+
//// 输出:-1
26+
27+
//
28+
//// CharSequence
29+
//String str = "Hello, world!";
30+
//str.chars().forEach(System.out::println);
31+
//str.chars().mapToObj(c -> (char) c).forEach(System.out::print);
32+
33+
//String str1 = "Hello";
34+
//String str2 = "world";
35+
//String str3 = str1 + str2;
36+
//String str4 = str1 + str2;
37+
//String str5 = "Hello" + "world";
38+
//String str6 = "Hello" + "world";
39+
//System.out.println(str3 == str4);
40+
//System.out.println(str5 == str6);
41+
42+
//String str1 = new StringBuilder("计算机").append("软件").toString();
43+
//System.out.println(str1.intern() == str1);
44+
//String str2 = new StringBuilder("ja").append("va").toString();
45+
//System.out.println(str2.intern() == str2);
46+
//
47+
//String b = "12";
48+
//String d = new StringBuilder("计算机").append("软件").toString();
49+
//String c = new StringBuilder("计算机").append("软件").toString();
50+
//String a = "计算机软件";
51+
//System.out.println(a == d);
52+
//System.out.println(a == c);
53+
String str0 = "abc";
54+
String str1 = new String("abc");
55+
String str3 = "abc";
56+
System.out.println(str1 == str0);
57+
System.out.println(str3 == str0);
58+
str1.intern();
59+
String str2 = new String("Hello,world");
60+
System.out.println(str1 == str2);
61+
}
62+
63+
public void test() {
64+
String str1 = "Hello, world!";
65+
String str2 = "Hello, world!";
66+
System.out.println(str1 == str2);
67+
}
68+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package com.wdbyte;
2+
3+
/**
4+
* @author niulang
5+
* @date 2023/03/30
6+
*/
7+
public class JavaStringBuilder {
8+
9+
public static void main(String[] args) {
10+
StringBuilder sb1 = new StringBuilder();
11+
System.out.println(sb1.capacity()); // 容量:16
12+
StringBuilder sb2 = new StringBuilder("wdbyte.com");
13+
System.out.println(sb2.capacity()); // 容量:26
14+
15+
StringBuilder sb3 = new StringBuilder("www");
16+
sb3.append(".wdbyte.com");
17+
System.out.println(sb3.toString()); //
18+
19+
StringBuilder sb4 = new StringBuilder("wdbyte");
20+
sb4.insert(0,"www.");
21+
System.out.println(sb4.toString()); // www.wdbyte
22+
sb4.insert(10,".com");
23+
System.out.println(sb4.toString()); // www.wdbyte.com
24+
25+
StringBuilder sb5 = new StringBuilder("www.wdbyte.com");
26+
sb5.delete(0,4);
27+
System.out.println(sb5); // wdbyte.com
28+
29+
StringBuilder sb6 = new StringBuilder("hello world!");
30+
sb6.replace(6,11, "java"); // 结果为 "hello java!"
31+
System.out.println(sb6);
32+
33+
StringBuilder sb7 = new StringBuilder("hello world!");
34+
sb7.reverse();
35+
System.out.println(sb7);
36+
37+
}
38+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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>core-java-modules</artifactId>
7+
<groupId>com.wdbyte.core-java-modules</groupId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
</parent>
10+
<modelVersion>4.0.0</modelVersion>
11+
12+
<artifactId>core-java-collect</artifactId>
13+
14+
<properties>
15+
<maven.compiler.source>8</maven.compiler.source>
16+
<maven.compiler.target>8</maven.compiler.target>
17+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
18+
</properties>
19+
20+
</project>

core-java-modules/pom.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
<module>core-java-io</module>
2727
<module>core-java-string</module>
2828
<module>core-java-18</module>
29+
<module>core-java-collect</module>
30+
<module>core-java-base</module>
2931
</modules>
3032

3133
</project>

tool-java-hotcode/.gitignore

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
target/
2+
!.mvn/wrapper/maven-wrapper.jar
3+
!**/src/main/**/target/
4+
!**/src/test/**/target/
5+
6+
### IntelliJ IDEA ###
7+
.idea/modules.xml
8+
.idea/jarRepositories.xml
9+
.idea/compiler.xml
10+
.idea/libraries/
11+
*.iws
12+
*.iml
13+
*.ipr
14+
15+
### Eclipse ###
16+
.apt_generated
17+
.classpath
18+
.factorypath
19+
.project
20+
.settings
21+
.springBeans
22+
.sts4-cache
23+
24+
### NetBeans ###
25+
/nbproject/private/
26+
/nbbuild/
27+
/dist/
28+
/nbdist/
29+
/.nb-gradle/
30+
build/
31+
!**/src/main/**/build/
32+
!**/src/test/**/build/
33+
34+
### VS Code ###
35+
.vscode/
36+
37+
### Mac OS ###
38+
.DS_Store

0 commit comments

Comments
 (0)