diff --git a/README.en.md b/README.en.md new file mode 100644 index 0000000000000000000000000000000000000000..b60ddf3b04021fcd0a14370d37a10d3276c1e9e9 --- /dev/null +++ b/README.en.md @@ -0,0 +1,88 @@ +# Java101 Sample Project + +This project is a collection of sample codes for learning and practicing the Java programming language. It covers basic syntax, data types, arrays, strings, OOP features, Scanner usage, JVM-related knowledge, and more. It is suitable for Java beginners and developers who wish to strengthen their foundational knowledge. + +## Project Structure + +The project is primarily divided into the following directories based on functionality and topics: + +- `array`: Contains sample code for array operations, such as array reversal, sorting, and filling. +- `data/type`: Covers Java primitive data types and their usage. +- `oop`: Demonstrates object-oriented programming concepts, such as method overriding. +- `scanner`: Shows how to use the `Scanner` class to read input from the console. +- `string`: Contains examples related to string concatenation and the string constant pool. +- `jvm/direct/memory`: Covers JVM direct memory operations, such as the use of `ByteBuffer` and `Unsafe` classes. +- `jvm/gc`: Contains examples related to garbage collection (GC). + +## Sample List + +Below are some key examples and their descriptions: + +### `array` Package Examples +- **Demo01Print.java**: Demonstrates how to print arrays. +- **Demo02Reverse.java**: Provides a method `getReverse` to reverse an array. +- **Demo03Arrays.java**: Uses the `Arrays` class to demonstrate array sorting and filling. +- **Demo04BubbleSort.java**: Implements the bubble sort algorithm. +- **Demo05ChessSheet.java**: Prints a chessboard matrix. + +### `data/type` Package Examples +- **Demo01NumericTypes.java**: Demonstrates numeric types in Java. +- **Demo02BasicTypeCast.java**: Demonstrates primitive type casting and binary and hexadecimal output of numbers. + +### `oop` Package Examples +- **Demo03Override.java**: Demonstrates the concept of method overriding (Override). + +### `scanner` Package Examples +- **Demo01NextLine.java**: Demonstrates the difference between `next` and `nextLine` methods in the `Scanner` class. +- **Demo02NextFloat.java**: Uses `Scanner` to read floating-point numbers. +- **Demo03SumAvg.java**: Reads multiple numbers and calculates their sum and average. + +### `string` Package Examples +- **Demo01Concat.java**: Demonstrates different methods of string concatenation. +- **Demo02Intern.java**: Demonstrates the use of the string constant pool (`intern()`) in Java. +- **Demo03StringTable.java**: Involves the use and testing of the string table. + +### `jvm` Package Examples +- **direct/memory/Demo01ByteBuffer.java**: Allocates direct memory using `ByteBuffer`. +- **direct/memory/Demo02Unsafe.java**: Performs unsafe memory operations using the `Unsafe` class. +- **gc/Demo01.java**: Demonstrates the basic concept of garbage collection. + +## Usage Instructions + +1. **Download the Code**: + Download or clone the code from the [Gitee repository](https://gitee.com/systerror/java101). + +2. **Compile the Code**: + Compile using the command line: + ```bash + javac -d out src/com/ror/java/se/**/*.java + ``` + +3. **Run the Examples**: + Run specific example classes using the `java` command, for example: + ```bash + java -cp out com.ror.java.se.array.Demo01Print + ``` + +## Learning Objectives + +This project aims to help developers master core Java programming concepts and common operations, including: +- Array usage and manipulation +- Primitive data types and type conversion +- String handling +- Fundamentals of object-oriented programming +- Console input handling +- JVM memory management and garbage collection + +## Contribution Guidelines + +Pull requests are welcome to help improve or add more examples! Please follow these rules: +1. The submitted code should clearly demonstrate a specific concept or feature. +2. Code should include good comments and follow naming conventions. +3. Test the code before submission to ensure it is error-free. + +## License + +This project uses the [MIT License](https://opensource.org/licenses/MIT). For details, please refer to the `LICENSE` file in the repository. + +For more information, please check the code and comments in each example class. \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000000000000000000000000000000000000..e9ce24e1e3ef03c6445d3ff3dafbafc23b4e6302 --- /dev/null +++ b/README.md @@ -0,0 +1,90 @@ + + +# Java101 示例项目 + +本项目是一系列用于学习和练习 Java 编程语言的示例代码,覆盖了基础语法、数据类型、数组、字符串、OOP 特性、Scanner 使用以及 JVM 相关知识等内容。适合 Java 初学者和希望巩固基础知识的开发者学习参考。 + +## 项目结构 + +项目主要按照功能和知识点划分为以下目录结构: + +- `array`: 包含数组相关操作的示例代码,例如数组反转、排序、填充等。 +- `data/type`: 涉及 Java 基本数据类型及其使用方式。 +- `oop`: 展示面向对象编程概念,如方法重写等。 +- `scanner`: 展示如何使用 `Scanner` 类从控制台读取输入。 +- `string`: 包含字符串拼接、字符串常量池等相关示例。 +- `jvm/direct/memory`: 涉及 JVM 直接内存操作,例如 `ByteBuffer` 和 `Unsafe` 类的使用。 +- `jvm/gc`: 包含与垃圾回收(GC)相关的示例。 + +## 示例列表 + +以下是一些关键示例及其功能描述: + +### `array` 包示例 +- **Demo01Print.java**: 展示如何打印数组。 +- **Demo02Reverse.java**: 提供一个方法 `getReverse` 用于反转数组。 +- **Demo03Arrays.java**: 使用 `Arrays` 类演示数组的排序与填充功能。 +- **Demo04BubbleSort.java**: 实现冒泡排序算法。 +- **Demo05ChessSheet.java**: 打印一个棋盘矩阵。 + +### `data/type` 包示例 +- **Demo01NumericTypes.java**: 展示 Java 中的数值类型。 +- **Demo02BasicTypeCast.java**: 演示基本类型转换及数字的二进制、十六进制输出。 + +### `oop` 包示例 +- **Demo03Override.java**: 演示方法重写(Override)的概念。 + +### `scanner` 包示例 +- **Demo01NextLine.java**: 演示 `Scanner` 类中 `next` 和 `nextLine` 的区别。 +- **Demo02NextFloat.java**: 使用 `Scanner` 读取浮点数。 +- **Demo03SumAvg.java**: 读取多个数字并计算其总和与平均值。 + +### `string` 包示例 +- **Demo01Concat.java**: 展示字符串拼接的不同方法。 +- **Demo02Intern.java**: 演示 Java 中字符串常量池 (`intern()`) 的使用。 +- **Demo03StringTable.java**: 涉及字符串表的使用和测试。 + +### `jvm` 包示例 +- **direct/memory/Demo01ByteBuffer.java**: 使用 `ByteBuffer` 分配直接内存。 +- **direct/memory/Demo02Unsafe.java**: 使用 `Unsafe` 类进行非安全内存操作。 +- **gc/Demo01.java**: 展示垃圾回收的基本概念。 + +## 使用方式 + +1. **下载代码**: + 从 [Gitee 仓库地址](https://gitee.com/systerror/java101) 下载或克隆代码。 + +2. **编译代码**: + 使用命令行编译: + ```bash + javac -d out src/com/ror/java/se/**/*.java + ``` + +3. **运行示例**: + 使用 `java` 命令运行特定示例类,例如: + ```bash + java -cp out com.ror.java.se.array.Demo01Print + ``` + +## 学习目标 + +该项目旨在帮助开发者掌握 Java 编程的核心基础概念和常用操作,包括: +- 数组的使用与操作 +- 基本数据类型与类型转换 +- 字符串处理 +- 面向对象编程基础 +- 控制台输入处理 +- JVM 内存管理与垃圾回收 + +## 贡献指南 + +欢迎提交 Pull Request,帮助我们改进或添加更多示例!请确保遵循以下规则: +1. 提交的代码需清晰展示特定知识点。 +2. 代码需有良好的注释和命名规范。 +3. 提交前测试代码确保无错误。 + +## 许可证 + +本项目使用 [MIT 许可证](https://opensource.org/licenses/MIT)。详情请查看仓库中的 `LICENSE` 文件。 + +如需进一步信息,请查看每个示例类中的代码和注释。 \ No newline at end of file