Skip to Content
学习 Java,第 6 版
book

学习 Java,第 6 版

by Marc Loy, Patrick Niemeyer, Daniel Leuck
May 2025
Intermediate to advanced
552 pages
7h 22m
Chinese
O'Reilly Media, Inc.
Content preview from 学习 Java,第 6 版

附录 A. 代码示例和 IntelliJ IDEA

本 附录将帮助你开始使用本书中的代码示例。这里的一些步骤在第2章中提到过,但我们想在这里稍微放慢速度,具体介绍如何在JetBrains公司免费提供的IntelliJ IDEA社区版中使用书中的示例。正如"安装 IntelliJ IDEA 和创建项目 "一文所述你可以从jetbrains.com网站获取 IntelliJ。如果您需要更多的设置帮助,他们还提供了出色的安装指南

安装 IDEA 后,您需要确保选择了最新版本的 JDK。(如果您还需要安装 Java 本身,"Installing the JDK"安装 JDK)中有各主要平台的详细信息)。图 A-1所示的 "文件"→"项目结构 "对话框允许您从已安装的任何 JDK 中进行选择。就本书而言,您至少需要 Java 19。您还需要将 "语言级别 "选项设置为所选 JDK 的预览版本。

ljv6 0A01
图 A-1. 在 IntelliJ IDEA 中启用 Java 的预览功能

在本例中,我们使用 Corretto 20 并选择 20(预览)语言级别。如果您想了解有关在 IntelliJ IDEA 中启用 Java 预览功能的更多信息,请在线查看他们的预览功能教程

我们还想重申的是,IntelliJ IDEA 并不是目前唯一的 Java 友好型集成开发环境。它甚至不是唯一免费的!微软的VS Code可以快速配置以支持 Java。由 IBM 维护的Eclipse 也仍然可用。初学者如果想寻找一种既能帮助他们轻松进行 Java 编程又能让他们轻松进入 Java 集成开发环境世界的工具,可以查看由伦敦国王学院创建的BlueJ

抓取主要代码示例

无论您使用哪种集成开发环境或编辑器,都可以从 GitHub 获取本书的代码示例。在讨论特定主题时,我们通常会包含完整的源代码列表,但很多时候,为了简洁和可读性,我们会选择省略importpackage 语句,或外层的class 结构。可下载的代码示例力求完整,以帮助加强书中的讨论。

您可以在浏览器中访问 GitHub,浏览各个示例,而无需下载任何内容。只需前往learnjava6e代码库即可。(如果链接失效,请访问github.com,搜索 "learnjava6e")。GitHub 已成为开源开发者甚至企业团队的主要 "水源",或许值得一探究竟。您可以查看版本库的历史,报告错误并讨论与代码相关的问题。

该网站的名称指的是Git工具,它是一种源代码控制系统或源代码管理器,开发人员用它来管理团队间代码项目的修订。但回顾图 2-14,你不必使用Git。你只需下载项目主分支的ZIP 压缩包,就能获取整批示例。下载完成后,将文件解压到一个可以轻松找到示例的文件夹中即可。你应该会看到与图 A-2 类似的文件夹结构。

ljv6 0A02
图 A-2. 代码示例的文件夹结构

如果你对 Git 很好奇,但你的系统还没有可用的git命令,可以从Git 网站下载。GitHub 也有自己的网站try.github.io 来帮助你了解Git。安装好Git

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

《学习 Python》第 5 版

《学习 Python》第 5 版

Mark Lutz
CSS:权威指南,第 5 版

CSS:权威指南,第 5 版

Eric Meyer, Estelle Weyl
詳解 システム・パフォーマンス 第2版

詳解 システム・パフォーマンス 第2版

Brendan Gregg, 西脇 靖紘, 長尾 高弘

Publisher Resources

ISBN: 9798341656772