Java 简介
Java 的主要特性、发展历史与常见开发工具。
主要特性
Java targets simple, object-oriented, portable, robust and secure code. It resembles C++ but drops pointers and multiple inheritance, manages memory with garbage collection, and hides platform differences behind the JVM.
- Platform independent — bytecode runs on any JVM
- Object-oriented — everything lives in a class
- Automatic memory management — GC reclaims objects
- Statically typed — types checked at compile time
- Multithreaded — built-in thread and lock support
- Strong ecosystem — Spring, Maven, huge library base
发展历史
Java was released in 1995 by James Gosling's team at Sun Microsystems, originally named Oak for embedded devices before pivoting to the web. Oracle acquired Sun in 2010 and now leads its evolution.
| Version | Year | Highlights |
|---|---|---|
| JDK 1.0 | 1996 | First release |
| Java 5 | 2004 | Generics, annotations, enum, for-each |
| Java 8 | 2014 | Lambda, Stream, new Date API |
| Java 11 | 2018 | LTS, var, HttpClient |
| Java 17 | 2021 | LTS, records, sealed classes |
| Java 21 | 2023 | LTS, virtual threads, pattern matching |
Java 开发工具
IntelliJ IDEA (free Community edition) is the usual editor, with Eclipse and VS Code + Extension Pack for Java as alternatives. Build with Maven or Gradle, and test with JUnit 5.
- IntelliJ IDEA — best refactoring and debugging
- Eclipse — long-standing, plugin-rich IDE
- Maven / Gradle — dependency and build management
- JUnit 5 — the standard testing framework
主要特性
Java 的设计目标是「简单、面向对象、跨平台、健壮、安全」。语法上接近 C++ 但去掉了指针与多重继承,用垃圾回收管理内存,用 JVM 屏蔽平台差异。
- 跨平台 —— 字节码可在任意 JVM 上运行
- 面向对象 —— 一切代码都在类中
- 自动内存管理 —— GC 回收对象
- 静态类型 —— 编译期检查类型
- 多线程 —— 内置线程与锁支持
- 生态强大 —— Spring、Maven 与庞大类库
发展历史
Java 由 Sun Microsystems 的 James Gosling 团队在 1995 年发布,最初叫 Oak,为家电嵌入式设计,后来转向互联网。2010 年 Sun 被 Oracle 收购,Java 由 Oracle 主导演进。
| 版本 | 年份 | 关键特性 |
|---|---|---|
| JDK 1.0 | 1996 | 首个正式版本 |
| Java 5 | 2004 | 泛型、注解、枚举、for-each |
| Java 8 | 2014 | Lambda、Stream、新日期 API |
| Java 11 | 2018 | LTS、var、HttpClient |
| Java 17 | 2021 | LTS、record、密封类 |
| Java 21 | 2023 | LTS、虚拟线程、模式匹配 |
Java 开发工具
编辑器首选 IntelliJ IDEA(社区版免费),其次 Eclipse 与 VS Code + Extension Pack for Java。构建工具用 Maven 或 Gradle,单元测试用 JUnit 5。
- IntelliJ IDEA —— 重构与调试体验最好
- Eclipse —— 老牌、插件丰富
- Maven / Gradle —— 依赖与构建管理
- JUnit 5 —— 标准测试框架