From d2ec04af7f7a5db74fe3976a9cae0f9bc264af3e Mon Sep 17 00:00:00 2001 From: "James Z. Zhang" <144994336+James-Z-Zhang00@users.noreply.github.com> Date: Thu, 13 Jun 2024 20:55:23 -0400 Subject: [PATCH 01/10] =?UTF-8?q?Java=20=E9=9D=A2=E8=AF=95=E5=87=86?= =?UTF-8?q?=E5=A4=87=E6=89=8B=E5=86=8C=20--=2050=E4=B8=AA=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E8=A7=A3=E7=AD=94=20+=20=E4=BB=A3=E7=A0=81=E7=A4=BA?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- chinese/articles/java-interview-prep-handbook.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chinese/articles/java-interview-prep-handbook.md b/chinese/articles/java-interview-prep-handbook.md index 2b200bdef..30bfb8340 100644 --- a/chinese/articles/java-interview-prep-handbook.md +++ b/chinese/articles/java-interview-prep-handbook.md @@ -3,7 +3,7 @@ title: The Java Interview Prep Handbook – 50 Questions Solved + Code Examples author: Vahe Aslanyan authorURL: https://www.freecodecamp.org/news/author/vahe/ originalURL: https://www.freecodecamp.org/news/java-interview-prep-handbook/ -translator: "" +translator: "James-Z-Zhang00" reviewer: "" --- @@ -2451,4 +2451,4 @@ Learn to code for free. freeCodeCamp's open source curriculum has helped more th [70]: https://tatevaslanyan.substack.com/ [71]: https://www.vaheaslanyan.com/ [72]: /news/author/vahe/ -[73]: https://www.freecodecamp.org/learn/ \ No newline at end of file +[73]: https://www.freecodecamp.org/learn/ From 38cc4e037d9a6f92d3f94a98cb63c8a2a1dd7023 Mon Sep 17 00:00:00 2001 From: James-Z-Zhang00 Date: Fri, 14 Jun 2024 00:56:30 +0000 Subject: [PATCH 02/10] Auto Format --- chinese/articles/coding-bootcamp-handbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chinese/articles/coding-bootcamp-handbook.md b/chinese/articles/coding-bootcamp-handbook.md index 12be5e235..55ff15692 100644 --- a/chinese/articles/coding-bootcamp-handbook.md +++ b/chinese/articles/coding-bootcamp-handbook.md @@ -389,7 +389,7 @@ Surprisingly, there are a few bootcamps that are for-profit but still free. And 要了解参加编码训练营的真实成本,你应该考虑机会成本。 -**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 +**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 这是你的真实成本,假设加上你在 6 个月的时间内找到工作并领取第一份薪水: From f0929fcecf9dbe560fd1caa9ce9f5eae4ea40146 Mon Sep 17 00:00:00 2001 From: "James Z. Zhang" <144994336+James-Z-Zhang00@users.noreply.github.com> Date: Thu, 13 Jun 2024 20:59:02 -0400 Subject: [PATCH 03/10] The first commit to confirm the branch location From ca544595e95c2c933765ea9760d5476299847d16 Mon Sep 17 00:00:00 2001 From: James-Z-Zhang00 Date: Fri, 14 Jun 2024 01:00:04 +0000 Subject: [PATCH 04/10] Auto Format --- chinese/articles/coding-bootcamp-handbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chinese/articles/coding-bootcamp-handbook.md b/chinese/articles/coding-bootcamp-handbook.md index 55ff15692..8c6d1bd43 100644 --- a/chinese/articles/coding-bootcamp-handbook.md +++ b/chinese/articles/coding-bootcamp-handbook.md @@ -389,7 +389,7 @@ Surprisingly, there are a few bootcamps that are for-profit but still free. And 要了解参加编码训练营的真实成本,你应该考虑机会成本。 -**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 +**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 这是你的真实成本,假设加上你在 6 个月的时间内找到工作并领取第一份薪水: From 757c9f02b8d0c4003e83ab574f953b37d0bf34da Mon Sep 17 00:00:00 2001 From: "James Z. Zhang" <144994336+James-Z-Zhang00@users.noreply.github.com> Date: Thu, 13 Jun 2024 21:16:05 -0400 Subject: [PATCH 05/10] Translated the beginning of the page --- chinese/articles/java-interview-prep-handbook.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/chinese/articles/java-interview-prep-handbook.md b/chinese/articles/java-interview-prep-handbook.md index 30bfb8340..ed65058e0 100644 --- a/chinese/articles/java-interview-prep-handbook.md +++ b/chinese/articles/java-interview-prep-handbook.md @@ -1,17 +1,19 @@ --- -title: The Java Interview Prep Handbook – 50 Questions Solved + Code Examples -author: Vahe Aslanyan -authorURL: https://www.freecodecamp.org/news/author/vahe/ -originalURL: https://www.freecodecamp.org/news/java-interview-prep-handbook/ -translator: "James-Z-Zhang00" +标题: Java 面试准备手册 -- 50个问题解答 + 代码示例 +作者: 瓦赫·艾斯兰扬 (Vahe Aslanyan) +作者URL: https://www.freecodecamp.org/news/author/vahe/ +原始URL: https://www.freecodecamp.org/news/java-interview-prep-handbook/ +译者: "James-Z-Zhang00" reviewer: "" --- December 7, 2023 / [#Java][1] +2023 年 12 月 7 日 / [#Java][1] # The Java Interview Prep Handbook – 50 Questions Solved + Code Examples +# Java 面试准备手册 -- 50个问题解答 + 代码示例 ![Vahe Aslanyan](https://www.freecodecamp.org/news/content/images/size/w60/2023/11/64f8cae0c5f6cb6d0b167833_1689535650919-transformed-p-500.jpeg) From f6b46cc12a6afa92953287445aee8b1802d3e72a Mon Sep 17 00:00:00 2001 From: James-Z-Zhang00 Date: Fri, 14 Jun 2024 01:17:09 +0000 Subject: [PATCH 06/10] Auto Format --- chinese/articles/coding-bootcamp-handbook.md | 2 +- chinese/articles/java-interview-prep-handbook.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/chinese/articles/coding-bootcamp-handbook.md b/chinese/articles/coding-bootcamp-handbook.md index 8c6d1bd43..bfa58bf89 100644 --- a/chinese/articles/coding-bootcamp-handbook.md +++ b/chinese/articles/coding-bootcamp-handbook.md @@ -389,7 +389,7 @@ Surprisingly, there are a few bootcamps that are for-profit but still free. And 要了解参加编码训练营的真实成本,你应该考虑机会成本。 -**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 +**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 这是你的真实成本,假设加上你在 6 个月的时间内找到工作并领取第一份薪水: diff --git a/chinese/articles/java-interview-prep-handbook.md b/chinese/articles/java-interview-prep-handbook.md index ed65058e0..5af3fcb23 100644 --- a/chinese/articles/java-interview-prep-handbook.md +++ b/chinese/articles/java-interview-prep-handbook.md @@ -13,7 +13,7 @@ December 7, 2023 / [#Java][1] # The Java Interview Prep Handbook – 50 Questions Solved + Code Examples -# Java 面试准备手册 -- 50个问题解答 + 代码示例 +# Java 面试准备手册 -- 50 个问题解答 + 代码示例 ![Vahe Aslanyan](https://www.freecodecamp.org/news/content/images/size/w60/2023/11/64f8cae0c5f6cb6d0b167833_1689535650919-transformed-p-500.jpeg) From 5eaab317c6a696e2eb155756d2ea8c3a8cbef532 Mon Sep 17 00:00:00 2001 From: "James Z. Zhang" <144994336+James-Z-Zhang00@users.noreply.github.com> Date: Tue, 23 Jul 2024 15:38:40 -0400 Subject: [PATCH 07/10] Until line 510 --- .../articles/java-interview-prep-handbook.md | 117 +++++++++++++++++- 1 file changed, 116 insertions(+), 1 deletion(-) diff --git a/chinese/articles/java-interview-prep-handbook.md b/chinese/articles/java-interview-prep-handbook.md index 5af3fcb23..6613cc466 100644 --- a/chinese/articles/java-interview-prep-handbook.md +++ b/chinese/articles/java-interview-prep-handbook.md @@ -22,14 +22,19 @@ December 7, 2023 / [#Java][1] ![The Java Interview Prep Handbook – 50 Questions Solved + Code Examples](https://www.freecodecamp.org/news/content/images/size/w2000/2023/12/The-Java-Interview-Prep-Handbook-Cover.png) If you're trying to get a job in big tech or you want to refine your skills in software development, a strong grasp of Java is indispensable. +如果你想在大科技公司找到一份工作,或者想提高你的软件开发技能,那么掌握Java是必不可少的。 Java is well-known for its robustness in Object-Oriented Programming (OOP), and it provides a comprehensive foundation essential for developers at every level. +Java以其在面向对象编程(OOP)中的稳健性而闻名,它为各级开发人员提供了至关重要的综合基础。 This handbook offers a detailed pathway to help you excel in Java interviews. It focuses on delivering insights and techniques relevant to roles in esteemed big tech companies, ensuring you're well-prepared for the challenges ahead. +本手册提供了一条详细的路径,帮助你在Java面试中表现出色。它专注于传授与知名大科技公司职位相关的见解和技术,确保你为未来的挑战做好充分准备。 This guide serves as a comprehensive Java review tutorial, bridging the gap between foundational Java knowledge and the sophisticated expertise sought by industry leaders like Google. And it'll help you deepen your understanding and practical application of Java, preparing you for professional success in the tech industry. +本指南作为全面的Java复习教程,弥合了基础Java知识与像Google这样行业领导者所寻求的高级专业知识之间的差距。它将帮助你加深对Java的理解和实际应用,为你在科技行业的职业成功做好准备。 ## Table of Contents +## 目录 1. [What is Java?][3] 2. [What's the difference between the JDK, JRE, and JVM?][4] @@ -83,31 +88,96 @@ This guide serves as a comprehensive Java review tutorial, bridging the gap betw 50. [Explain the concept of modules in Java][52] 51. [Conclusion][53] +1. [什么是Java?][3] +2. [JDK、JRE和JVM之间有什么区别?][4] +3. [‘public static void main(String args)’ 方法是如何工作的?][5] +4. [Java中的字节码是什么?][6] +5. [重载和重写有什么区别?][7] +6. [什么是Java ClassLoader?][8] +7. [我们可以重写Java中的静态方法吗?][9] +8. [‘finally’块与Java中的‘finalize’方法有何不同?][10] +9. [抽象类和接口有什么区别?][11] +10. [解释Java包的概念][12] +11. [什么是Java注解?][13] +12. [Java中的多线程是如何工作的?][14] +13. [使用throw抛出异常][15] +14. [使用throws声明异常][16] +15. [transient关键字的意义是什么?][17] +16. [如何确保Java中的线程安全?][18] +17. [解释单例模式][19] +18. [什么是Java流(Streams)?][20] +19. [ArrayList和LinkedList的主要区别是什么?][21] +20. [HashSet、LinkedHashSet和TreeSet有何不同?][22] +21. [区分HashMap和ConcurrentHashMap][23] +22. [描述hashCode()和equals()方法之间的契约][24] +23. [什么是Java反射(reflection)?][25] +24. [如何在Java中创建自定义异常?][26] +25. [受检异常和非受检异常有什么区别?][27] +26. [什么是泛型?为什么要使用泛型?][28] +27. [解释Java Lambda表达式的概念][29] +28. [继承中的菱形问题是什么?][30] +29. [描述fail-fast和fail-safe迭代器的区别][31] +30. [什么是Java泛型中的类型擦除?][32] +31. [描述StringBuilder和StringBuffer之间的区别][33] +32. [Java中的volatile关键字是什么?][34] +33. [解释Java内存模型][35] +34. [接口中的default关键字的用途是什么?][36] +35. [Java 7和Java 8中的switch有何不同?][37] +36. [解释自动装箱和拆箱的概念][38] +37. [描述@FunctionalInterface注解][39] +38. [如何在Java中实现不可变性?][40] +39. [什么是装饰器模式?][41] +40. [解释Java I/O流][42] +41. [Java中的垃圾收集器如何工作?][43] +42. [使用Java NIO的好处是什么?][44] +43. [解释观察者模式][45] +44. [Java的Optional的用途是什么?][46] +45. [解释Java的try-with-resources][47] +46. [解释C++和Java的区别][48] +47. [什么是多态?举例说明][49] +48. [如何避免Java中的内存泄漏?][50] +49. [解释Java的同步块的用途][51] +50. [解释Java中的模块概念][52] +51. [结论][53] + ![image-23](https://www.freecodecamp.org/news/content/images/2023/12/image-23.png) Butterfly representing the potential of Java - [lunartech.ai][54] +蝴蝶代表Java的潜力 - [lunartech.ai][54] ## 1\. What is Java? +## 1\. Java是什么? Java is a high-level, object-oriented programming language known for its platform independence. It allows developers to write code once and run it anywhere using the Java Virtual Machine (JVM). +Java是一种高级的面向对象编程语言,以其平台独立性而闻名。它允许开发人员编写一次代码,并通过Java虚拟机(JVM)在任何地方运行。 -## 2\. What's the Difference between the JDK, JRE, and JVM? +## 2\. JDK、JRE 和 JVM 之间有什么区别? - **JDK (Java Development Kit):** This is a software package that provides developers with the tools and utilities necessary to develop, compile, and run Java applications. - **JRE (Java Runtime Environment):** A subset of the JDK, the JRE contains the essential components, including the JVM, to run Java applications but not to develop them. - **JVM (Java Virtual Machine):** An abstract computing machine, the JVM enables Java bytecode to be executed, providing the platform independence Java is known for. +- **JDK(Java Development Kit,Java开发工具包):** 这是一个软件包,为开发人员提供开发、编译和运行Java应用程序所需的工具和实用程序。 +- **JRE(Java Runtime Environment,Java运行环境):** JRE是JDK的一个子集,包含运行Java应用程序的必要组件,包括JVM,但不包括开发工具。 +- **JVM(Java Virtual Machine,Java虚拟机):** JVM是一种抽象的计算机,它使Java字节码得以执行,从而提供了Java所知的跨平台能力。 + ## 3\. How Does the `public static void main(String[] args)` Method Work? +## 3\. `public static void main(String[] args)` 方法是如何工作的? This method is the entry point for Java applications. The `public` modifier means it's accessible from other classes, `static` denotes it's a class-level method, and `void` indicates it doesn't return any value. The argument `String[] args` allows command-line arguments to be passed to the application. +这个方法是Java应用程序的入口点。`public` 修饰符意味着它可以从其他类访问,`static` 表示它是一个类级别的方法,`void` 表明它不返回任何值。参数 `String[] args` 允许将命令行参数传递给应用程序。 ## 4\. What is bytecode in Java? +## 4\. 什么是Java中的字节码? Bytecode is an intermediate, platform-independent code that Java source code is compiled into. It is executed by the JVM, enabling the "write once, run anywhere" capability. +字节码是 Java 源代码编译成的一种中间, 平台无关的代码。它由 JVM 执行, 从而实现 "编写一次,到处运行" 的能力。 ## 5\. Differentiate between overloading and overriding +## 5\. 重载和重写的区别 - **Overloading:** This occurs when two or more methods in the same class share the same name but have different parameters. It's a compile-time concept. +- **重载(Overloading):** 当同一个类中有两个或多个方法共享相同的名称但具有不同的参数时,就发生了重载。这是一个编译时概念。 ``` class MathOperation { @@ -144,6 +214,7 @@ public class Main { ``` - **Overriding:** In this case, a subclass provides a specific implementation for a method already defined in its superclass. It's a runtime concept. +- **重写(Overriding):** 在这种情况下,子类为其超类中已定义的方法提供特定的实现。这是一个运行时概念。 ``` class Animal { @@ -180,22 +251,32 @@ public class Main { Swirling gears symbolize dynamic Java class loading. - [lunartech.ai][55] ## 6\. What is the Java ClassLoader? +## 6\. 什么是Java ClassLoader? The Java ClassLoader is a part of the JRE that dynamically loads Java classes into the JVM during runtime. It plays a crucial role in Java's runtime environment by extending the core Java classes. +Java ClassLoader 是 JRE 的一部分,在运行时动态加载 Java 类到 JVM 中。它通过扩展核心 Java 类,在 Java 的运行时环境中发挥了重要作用。 ## 7\. Can We Override Static Methods in Java? +## 7\. 我们可以重写Java中的静态方法吗? No, we cannot override static methods. While a subclass can declare a method with the same name as a static method in its superclass, this is considered method hiding, not overriding. +不,我们不能重写静态方法。虽然子类可以声明一个与其超类中的静态方法同名的方法,但这被认为是方法隐藏,而不是重写。 ## 8\. How Does the `finally` Block Differ from the `finalize` Method in Java? +## 8\. `finally` 块与 Java 中的 `finalize` 方法有何不同? Understanding the distinction between the `finally` block and the `finalize` method in Java is crucial for effective resource management and exception handling in your programs. +理解 `finally` 块和 `finalize` 方法之间的区别对于有效的资源管理和异常处理至关重要。 **Finally Block:** +**Finally块:** - **Purpose and Usage:** The `finally` block is a key component of Java's exception handling mechanism. It is used in conjunction with `try-catch` blocks. - **Execution Guarantee:** Regardless of whether an exception is thrown or caught within the `try` or `catch` blocks, the code within the `finally` block is always executed. This ensures that it runs even if there’s a return statement in the `try` or `catch` block. - **Common Uses:** It is typically utilized for cleaning up resources, such as closing file streams, database connections, or releasing any system resources that were acquired in the `try` block. This helps in preventing resource leaks. +- **目的和用法:** `finally` 块是Java异常处理机制的关键组成部分。它与 `try-catch` 块一起使用。 +- **执行保证:** 无论在 `try` 或 `catch` 块中是否抛出或捕获异常,`finally` 块中的代码总是会执行。这确保了即使在 `try` 或 `catch` 块中有return语句,`finally` 块中的代码也会运行。 +- **常见用途:** 它通常用于清理资源,如关闭文件流、数据库连接或释放 `try` 块中获取的任何系统资源。这有助于防止资源泄漏。 ``` public class FinallyDemo { @@ -212,11 +293,16 @@ public class FinallyDemo { ``` **Finalize Method:** +**Finalize方法:** - **Definition:** The `finalize` method is a protected method of the `Object` class in Java. It acts as a final resort for objects garbage collection. - **Garbage Collector Call:** It is called by the garbage collector on an object when the garbage collector determines that there are no more references to the object. However, its execution is not guaranteed, and it's generally unpredictable when, or even if, the `finalize` method will be invoked. - **Resource Release:** The `finalize` method is designed to allow an object to clean up its resources before it is collected by the garbage collector. For example, it might be used to ensure that an open file owned by an object is closed. - **Caution in Use:** It's important to note that relying on `finalize` for resource cleanup is generally not recommended due to its unpredictability and potential impact on performance. +- **定义:** `finalize` 方法是 Java 中 `Object` 类的一个受保护的方法。它作为对象垃圾收集的最后手段。 +- **垃圾收集器调用:** 当垃圾收集器确定一个对象不再有引用时,它会在该对象上调用 `finalize` 方法。然而,它的执行并不保证,而且通常无法预测 `finalize` 方法何时会被调用,甚至是否会被调用。 +- **资源释放:** `finalize` 方法旨在允许对象在被垃圾收集器回收之前清理其资源。例如,它可能用于确保对象拥有的打开文件被关闭。 +- **使用注意:** 需要注意的是,由于其不可预测性和潜在的性能影响,依赖 `finalize` 进行资源清理通常是不推荐的。 ``` public class FinalizeDemo { @@ -233,8 +319,10 @@ public class FinalizeDemo { ``` **Access Modifiers in Java:** +**Java中的访问修饰符:** - **Private:** This modifier makes a member accessible only within its own class. Other classes cannot access private members of a different class. +- **Private(私有):** 这种修饰符使成员只能在其所属的类内访问。其他类不能访问不同类的私有成员。 ``` class PrivateDemo { @@ -247,6 +335,7 @@ class PrivateDemo { ``` - **Default (no modifier):** When no access modifier is specified, the member has package-level access. This means it is accessible to all classes within the same package. +- **Default(默认,无修饰符):** 当未指定访问修饰符时,该成员具有包级访问权限。这意味着它可以被同一包中的所有类访问。 ``` class DefaultDemo { @@ -259,6 +348,7 @@ class DefaultDemo { ``` - **Protected:** A protected member is accessible within its own package and also in subclasses. This is often used in inheritance. +- **Protected(受保护):** 受保护的成员在其所在包内以及在子类中都是可访问的。这通常用于继承中。 ``` class ProtectedDemo { @@ -271,6 +361,7 @@ class ProtectedDemo { ``` - **Public:** Public members are accessible from any class in the Java program. It provides the widest level of access. +- **Public(公共):** 公共成员可以被Java程序中的任何类访问。它提供了最广泛的访问级别。 ``` public class PublicDemo { @@ -283,14 +374,19 @@ public class PublicDemo { ``` Understanding these distinctions and access levels is vital for effective Java programming, ensuring resource management, security, and encapsulation are handled appropriately in your software development endeavors. +理解这些区别和访问级别对于有效的Java编程至关重要,可以确保在软件开发过程中适当地处理资源管理、安全性和封装。 ## 9\. What is the Difference between an Abstract Class and an Interface? +## 9\. 抽象类和接口之间有什么区别? An abstract class in Java is used as a base for other classes. It can contain both abstract methods (without an implementation) and concrete methods (with an implementation). +在Java中,抽象类用作其他类的基类。它可以包含抽象方法(没有实现)和具体方法(有实现)。 Abstract classes can have member variables that can be inherited by subclasses. A class can extend only one abstract class due to Java's single inheritance property. +抽象类可以有成员变量,子类可以继承这些成员变量。由于Java的单继承特性,一个类只能继承一个抽象类。 **Example of an Abstract Class:** +**抽象类的示例:** ``` abstract class Shape { @@ -329,10 +425,13 @@ public class Main { ``` An interface in Java, on the other hand, is a completely "abstract class" that is used to group related methods with empty bodies. +在Java中,接口则是一个完全的“抽象类”,用于将相关的方法组织在一起,这些方法只有方法签名,没有方法体。 From Java 8 onwards, interfaces can have default and static methods with a body. A class can implement any number of interfaces. +从Java 8开始,接口可以包含具有方法体的默认方法和静态方法。一个类可以实现任意数量的接口。 **Example of an Interface:** +**接口的示例:** ``` interface Drawable { @@ -360,40 +459,56 @@ public class Main { ``` Both abstract classes and interfaces are foundational concepts in Java, used for achieving abstraction and supporting design patterns like Strategy and Adapter. The use of these concepts depends on the specific requirements and design considerations of your software project. +抽象类和接口是Java中的基础概念,用于实现抽象和支持设计模式,如策略模式(Strategy)和适配器模式(Adapter)。这两个概念的使用取决于软件项目的具体需求和设计考虑。 ![image-25](https://www.freecodecamp.org/news/content/images/2023/12/image-25.png) Luminous labyrinth depicts Java packages and threading. - [lunartech.ai][56] ## 10\. Explain the Concept of Java Packages +## 10\. 解释Java包的概念 Java packages are a way of organizing and structuring classes and interfaces in Java applications. They provide a means to group related code together. Packages help prevent naming conflicts, enhance code readability, and facilitate code reusability. +Java包是一种组织和结构化Java应用程序中的类和接口的方式。它们提供了将相关代码分组在一起的手段。包有助于防止命名冲突,提高代码可读性,并促进代码重用。 For example, consider a banking application. You might have packages like `com.bank.accounts`, `com.bank.customers`, and `com.bank.transactions`. These packages contain classes and interfaces specific to their respective functionalities. +例如,考虑一个银行应用程序。你可能会有像 `com.bank.accounts` 、`com.bank.customers` 和 `com.bank.transactions` 这样的包。这些包包含特定功能的类和接口。 In essence, Java packages are like directories or folders in a file system, organizing code and making it more manageable. +本质上,Java包就像文件系统中的目录或文件夹,组织代码并使其更易于管理。 ## 11\. What are Java Annotations? +## 11\. 什么是Java注解? Java annotations are metadata that can be added to Java source code. They provide information about the code to the compiler or runtime environment. Annotations do not directly affect the program's functionality – instead, they convey instructions to tools or frameworks. +Java注解是可以添加到Java源代码中的元数据。它们为编译器或运行时环境提供有关代码的信息。注解不会直接影响程序的功能——它们提供指令给工具或框架。 A common use of annotations is for marking classes or methods as belonging to a specific framework or for providing additional information to tools like code analyzers, build tools, or even custom code generators. +注解的常见用途是标记类或方法属于特定框架,或为代码分析工具、构建工具甚至自定义代码生成器提供额外的信息。 For example, the `@Override` annotation indicates that a method is intended to override a method from a superclass, helping catch coding errors during compilation. Another example is `@Deprecated`, which indicates that a method or class is no longer recommended for use. +例如,`@Override` 注解表明一个方法旨在重写超类中的方法,帮助在编译期间捕获编码错误。另一个例子是 `@Deprecated`,它表明一个方法或类不再推荐使用。 ## 12\. How Does Multi-threading Work in Java? +## 12\. Java中的多线程是如何工作的? Multi-threading in Java allows a program to execute multiple threads concurrently. Threads are lightweight processes within a program that can run independently. Java provides a rich set of APIs and built-in support for multi-threading. +Java中的多线程允许程序同时执行多个线程。线程是程序中的轻量级进程,可以独立运行。Java提供了丰富的API和内置支持来实现多线程。 Threads in Java are typically created by either extending the `Thread` class or implementing the `Runnable` interface. Once created, threads can be started using the `start()` method, causing them to run concurrently. +Java中的线程通常通过扩展 `Thread` 类或实现 `Runnable` 接口来创建。创建线程后,可以使用 `start()` 方法启动它们,使它们并发运行。 Java's multi-threading model ensures that threads share resources like memory and CPU time efficiently while providing mechanisms like synchronization and locks to control access to shared data. +Java的多线程模型确保线程有效地共享内存和CPU时间,同时提供了如同步和锁等机制来控制对共享数据的访问。 Multi-threading is useful for tasks such as improving application responsiveness, utilizing multi-core processors, and handling concurrent operations, as often seen in server applications. +多线程对于提高应用程序响应性、利用多核处理器以及处理并发操作(如服务器应用程序中常见的)非常有用。 ## 13\. Use `throw` to Raise an Exception +## 13\. 使用 `throw` 来抛出异常 In Java programming, the `throw` keyword is crucial for handling exceptions deliberately and responsively. This approach to exception management allows developers to enforce specific conditions in their code and maintain control over the program flow. +在Java编程中,`throw` 关键字对于有意和响应性地处理异常至关重要。这种异常管理方法允许开发人员在代码中强制特定条件,并控制程序流程。 ```java public void verifyAge(int age) { From fe0f3175c94d6aa84ba0a7332927dfe0ca842c10 Mon Sep 17 00:00:00 2001 From: James-Z-Zhang00 Date: Tue, 23 Jul 2024 19:39:40 +0000 Subject: [PATCH 08/10] Auto Format --- chinese/articles/coding-bootcamp-handbook.md | 2 +- .../articles/java-interview-prep-handbook.md | 150 +++++++++--------- 2 files changed, 76 insertions(+), 76 deletions(-) diff --git a/chinese/articles/coding-bootcamp-handbook.md b/chinese/articles/coding-bootcamp-handbook.md index bfa58bf89..62d9aff9b 100644 --- a/chinese/articles/coding-bootcamp-handbook.md +++ b/chinese/articles/coding-bootcamp-handbook.md @@ -389,7 +389,7 @@ Surprisingly, there are a few bootcamps that are for-profit but still free. And 要了解参加编码训练营的真实成本,你应该考虑机会成本。 -**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 +**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 这是你的真实成本,假设加上你在 6 个月的时间内找到工作并领取第一份薪水: diff --git a/chinese/articles/java-interview-prep-handbook.md b/chinese/articles/java-interview-prep-handbook.md index 6613cc466..ac87b98d4 100644 --- a/chinese/articles/java-interview-prep-handbook.md +++ b/chinese/articles/java-interview-prep-handbook.md @@ -22,16 +22,16 @@ December 7, 2023 / [#Java][1] ![The Java Interview Prep Handbook – 50 Questions Solved + Code Examples](https://www.freecodecamp.org/news/content/images/size/w2000/2023/12/The-Java-Interview-Prep-Handbook-Cover.png) If you're trying to get a job in big tech or you want to refine your skills in software development, a strong grasp of Java is indispensable. -如果你想在大科技公司找到一份工作,或者想提高你的软件开发技能,那么掌握Java是必不可少的。 +如果你想在大科技公司找到一份工作,或者想提高你的软件开发技能,那么掌握 Java 是必不可少的。 Java is well-known for its robustness in Object-Oriented Programming (OOP), and it provides a comprehensive foundation essential for developers at every level. -Java以其在面向对象编程(OOP)中的稳健性而闻名,它为各级开发人员提供了至关重要的综合基础。 +Java 以其在面向对象编程(OOP)中的稳健性而闻名,它为各级开发人员提供了至关重要的综合基础。 This handbook offers a detailed pathway to help you excel in Java interviews. It focuses on delivering insights and techniques relevant to roles in esteemed big tech companies, ensuring you're well-prepared for the challenges ahead. -本手册提供了一条详细的路径,帮助你在Java面试中表现出色。它专注于传授与知名大科技公司职位相关的见解和技术,确保你为未来的挑战做好充分准备。 +本手册提供了一条详细的路径,帮助你在 Java 面试中表现出色。它专注于传授与知名大科技公司职位相关的见解和技术,确保你为未来的挑战做好充分准备。 This guide serves as a comprehensive Java review tutorial, bridging the gap between foundational Java knowledge and the sophisticated expertise sought by industry leaders like Google. And it'll help you deepen your understanding and practical application of Java, preparing you for professional success in the tech industry. -本指南作为全面的Java复习教程,弥合了基础Java知识与像Google这样行业领导者所寻求的高级专业知识之间的差距。它将帮助你加深对Java的理解和实际应用,为你在科技行业的职业成功做好准备。 +本指南作为全面的 Java 复习教程,弥合了基础 Java 知识与像 Google 这样行业领导者所寻求的高级专业知识之间的差距。它将帮助你加深对 Java 的理解和实际应用,为你在科技行业的职业成功做好准备。 ## Table of Contents ## 目录 @@ -88,68 +88,68 @@ This guide serves as a comprehensive Java review tutorial, bridging the gap betw 50. [Explain the concept of modules in Java][52] 51. [Conclusion][53] -1. [什么是Java?][3] -2. [JDK、JRE和JVM之间有什么区别?][4] +1. [什么是 Java?][3] +2. [JDK、JRE 和 JVM 之间有什么区别?][4] 3. [‘public static void main(String args)’ 方法是如何工作的?][5] -4. [Java中的字节码是什么?][6] +4. [Java 中的字节码是什么?][6] 5. [重载和重写有什么区别?][7] -6. [什么是Java ClassLoader?][8] -7. [我们可以重写Java中的静态方法吗?][9] -8. [‘finally’块与Java中的‘finalize’方法有何不同?][10] +6. [什么是 Java ClassLoader?][8] +7. [我们可以重写 Java 中的静态方法吗?][9] +8. [‘finally’块与 Java 中的‘finalize’方法有何不同?][10] 9. [抽象类和接口有什么区别?][11] -10. [解释Java包的概念][12] -11. [什么是Java注解?][13] -12. [Java中的多线程是如何工作的?][14] -13. [使用throw抛出异常][15] -14. [使用throws声明异常][16] -15. [transient关键字的意义是什么?][17] -16. [如何确保Java中的线程安全?][18] +10. [解释 Java 包的概念][12] +11. [什么是 Java 注解?][13] +12. [Java 中的多线程是如何工作的?][14] +13. [使用 throw 抛出异常][15] +14. [使用 throws 声明异常][16] +15. [transient 关键字的意义是什么?][17] +16. [如何确保 Java 中的线程安全?][18] 17. [解释单例模式][19] -18. [什么是Java流(Streams)?][20] -19. [ArrayList和LinkedList的主要区别是什么?][21] -20. [HashSet、LinkedHashSet和TreeSet有何不同?][22] -21. [区分HashMap和ConcurrentHashMap][23] -22. [描述hashCode()和equals()方法之间的契约][24] -23. [什么是Java反射(reflection)?][25] -24. [如何在Java中创建自定义异常?][26] +18. [什么是 Java 流(Streams)?][20] +19. [ArrayList 和 LinkedList 的主要区别是什么?][21] +20. [HashSet、LinkedHashSet 和 TreeSet 有何不同?][22] +21. [区分 HashMap 和 ConcurrentHashMap][23] +22. [描述 hashCode()和 equals()方法之间的契约][24] +23. [什么是 Java 反射(reflection)?][25] +24. [如何在 Java 中创建自定义异常?][26] 25. [受检异常和非受检异常有什么区别?][27] 26. [什么是泛型?为什么要使用泛型?][28] -27. [解释Java Lambda表达式的概念][29] +27. [解释 Java Lambda 表达式的概念][29] 28. [继承中的菱形问题是什么?][30] -29. [描述fail-fast和fail-safe迭代器的区别][31] -30. [什么是Java泛型中的类型擦除?][32] -31. [描述StringBuilder和StringBuffer之间的区别][33] -32. [Java中的volatile关键字是什么?][34] -33. [解释Java内存模型][35] -34. [接口中的default关键字的用途是什么?][36] -35. [Java 7和Java 8中的switch有何不同?][37] +29. [描述 fail-fast 和 fail-safe 迭代器的区别][31] +30. [什么是 Java 泛型中的类型擦除?][32] +31. [描述 StringBuilder 和 StringBuffer 之间的区别][33] +32. [Java 中的 volatile 关键字是什么?][34] +33. [解释 Java 内存模型][35] +34. [接口中的 default 关键字的用途是什么?][36] +35. [Java 7 和 Java 8 中的 switch 有何不同?][37] 36. [解释自动装箱和拆箱的概念][38] -37. [描述@FunctionalInterface注解][39] -38. [如何在Java中实现不可变性?][40] +37. [描述@FunctionalInterface 注解][39] +38. [如何在 Java 中实现不可变性?][40] 39. [什么是装饰器模式?][41] -40. [解释Java I/O流][42] -41. [Java中的垃圾收集器如何工作?][43] -42. [使用Java NIO的好处是什么?][44] +40. [解释 Java I/O 流][42] +41. [Java 中的垃圾收集器如何工作?][43] +42. [使用 Java NIO 的好处是什么?][44] 43. [解释观察者模式][45] -44. [Java的Optional的用途是什么?][46] -45. [解释Java的try-with-resources][47] -46. [解释C++和Java的区别][48] +44. [Java 的 Optional 的用途是什么?][46] +45. [解释 Java 的 try-with-resources][47] +46. [解释 C++和 Java 的区别][48] 47. [什么是多态?举例说明][49] -48. [如何避免Java中的内存泄漏?][50] -49. [解释Java的同步块的用途][51] -50. [解释Java中的模块概念][52] +48. [如何避免 Java 中的内存泄漏?][50] +49. [解释 Java 的同步块的用途][51] +50. [解释 Java 中的模块概念][52] 51. [结论][53] ![image-23](https://www.freecodecamp.org/news/content/images/2023/12/image-23.png) Butterfly representing the potential of Java - [lunartech.ai][54] -蝴蝶代表Java的潜力 - [lunartech.ai][54] +蝴蝶代表 Java 的潜力 - [lunartech.ai][54] ## 1\. What is Java? -## 1\. Java是什么? +## 1. Java 是什么? Java is a high-level, object-oriented programming language known for its platform independence. It allows developers to write code once and run it anywhere using the Java Virtual Machine (JVM). -Java是一种高级的面向对象编程语言,以其平台独立性而闻名。它允许开发人员编写一次代码,并通过Java虚拟机(JVM)在任何地方运行。 +Java 是一种高级的面向对象编程语言,以其平台独立性而闻名。它允许开发人员编写一次代码,并通过 Java 虚拟机(JVM)在任何地方运行。 ## 2\. JDK、JRE 和 JVM 之间有什么区别? @@ -157,18 +157,18 @@ Java是一种高级的面向对象编程语言,以其平台独立性而闻名 - **JRE (Java Runtime Environment):** A subset of the JDK, the JRE contains the essential components, including the JVM, to run Java applications but not to develop them. - **JVM (Java Virtual Machine):** An abstract computing machine, the JVM enables Java bytecode to be executed, providing the platform independence Java is known for. -- **JDK(Java Development Kit,Java开发工具包):** 这是一个软件包,为开发人员提供开发、编译和运行Java应用程序所需的工具和实用程序。 -- **JRE(Java Runtime Environment,Java运行环境):** JRE是JDK的一个子集,包含运行Java应用程序的必要组件,包括JVM,但不包括开发工具。 -- **JVM(Java Virtual Machine,Java虚拟机):** JVM是一种抽象的计算机,它使Java字节码得以执行,从而提供了Java所知的跨平台能力。 +- **JDK(Java Development Kit,Java 开发工具包):** 这是一个软件包,为开发人员提供开发、编译和运行 Java 应用程序所需的工具和实用程序。 +- **JRE(Java Runtime Environment,Java 运行环境):** JRE 是 JDK 的一个子集,包含运行 Java 应用程序的必要组件,包括 JVM,但不包括开发工具。 +- **JVM(Java Virtual Machine,Java 虚拟机):** JVM 是一种抽象的计算机,它使 Java 字节码得以执行,从而提供了 Java 所知的跨平台能力。 ## 3\. How Does the `public static void main(String[] args)` Method Work? ## 3\. `public static void main(String[] args)` 方法是如何工作的? This method is the entry point for Java applications. The `public` modifier means it's accessible from other classes, `static` denotes it's a class-level method, and `void` indicates it doesn't return any value. The argument `String[] args` allows command-line arguments to be passed to the application. -这个方法是Java应用程序的入口点。`public` 修饰符意味着它可以从其他类访问,`static` 表示它是一个类级别的方法,`void` 表明它不返回任何值。参数 `String[] args` 允许将命令行参数传递给应用程序。 +这个方法是 Java 应用程序的入口点。`public` 修饰符意味着它可以从其他类访问,`static` 表示它是一个类级别的方法,`void` 表明它不返回任何值。参数 `String[] args` 允许将命令行参数传递给应用程序。 ## 4\. What is bytecode in Java? -## 4\. 什么是Java中的字节码? +## 4. 什么是 Java 中的字节码? Bytecode is an intermediate, platform-independent code that Java source code is compiled into. It is executed by the JVM, enabling the "write once, run anywhere" capability. 字节码是 Java 源代码编译成的一种中间, 平台无关的代码。它由 JVM 执行, 从而实现 "编写一次,到处运行" 的能力。 @@ -251,13 +251,13 @@ public class Main { Swirling gears symbolize dynamic Java class loading. - [lunartech.ai][55] ## 6\. What is the Java ClassLoader? -## 6\. 什么是Java ClassLoader? +## 6. 什么是 Java ClassLoader? The Java ClassLoader is a part of the JRE that dynamically loads Java classes into the JVM during runtime. It plays a crucial role in Java's runtime environment by extending the core Java classes. Java ClassLoader 是 JRE 的一部分,在运行时动态加载 Java 类到 JVM 中。它通过扩展核心 Java 类,在 Java 的运行时环境中发挥了重要作用。 ## 7\. Can We Override Static Methods in Java? -## 7\. 我们可以重写Java中的静态方法吗? +## 7. 我们可以重写 Java 中的静态方法吗? No, we cannot override static methods. While a subclass can declare a method with the same name as a static method in its superclass, this is considered method hiding, not overriding. 不,我们不能重写静态方法。虽然子类可以声明一个与其超类中的静态方法同名的方法,但这被认为是方法隐藏,而不是重写。 @@ -269,13 +269,13 @@ Understanding the distinction between the `finally` block and the `finalize` met 理解 `finally` 块和 `finalize` 方法之间的区别对于有效的资源管理和异常处理至关重要。 **Finally Block:** -**Finally块:** +**Finally 块:** - **Purpose and Usage:** The `finally` block is a key component of Java's exception handling mechanism. It is used in conjunction with `try-catch` blocks. - **Execution Guarantee:** Regardless of whether an exception is thrown or caught within the `try` or `catch` blocks, the code within the `finally` block is always executed. This ensures that it runs even if there’s a return statement in the `try` or `catch` block. - **Common Uses:** It is typically utilized for cleaning up resources, such as closing file streams, database connections, or releasing any system resources that were acquired in the `try` block. This helps in preventing resource leaks. -- **目的和用法:** `finally` 块是Java异常处理机制的关键组成部分。它与 `try-catch` 块一起使用。 -- **执行保证:** 无论在 `try` 或 `catch` 块中是否抛出或捕获异常,`finally` 块中的代码总是会执行。这确保了即使在 `try` 或 `catch` 块中有return语句,`finally` 块中的代码也会运行。 +- **目的和用法:** `finally` 块是 Java 异常处理机制的关键组成部分。它与 `try-catch` 块一起使用。 +- **执行保证:** 无论在 `try` 或 `catch` 块中是否抛出或捕获异常,`finally` 块中的代码总是会执行。这确保了即使在 `try` 或 `catch` 块中有 return 语句,`finally` 块中的代码也会运行。 - **常见用途:** 它通常用于清理资源,如关闭文件流、数据库连接或释放 `try` 块中获取的任何系统资源。这有助于防止资源泄漏。 ``` @@ -293,7 +293,7 @@ public class FinallyDemo { ``` **Finalize Method:** -**Finalize方法:** +**Finalize 方法:** - **Definition:** The `finalize` method is a protected method of the `Object` class in Java. It acts as a final resort for objects garbage collection. - **Garbage Collector Call:** It is called by the garbage collector on an object when the garbage collector determines that there are no more references to the object. However, its execution is not guaranteed, and it's generally unpredictable when, or even if, the `finalize` method will be invoked. @@ -319,7 +319,7 @@ public class FinalizeDemo { ``` **Access Modifiers in Java:** -**Java中的访问修饰符:** +**Java 中的访问修饰符:** - **Private:** This modifier makes a member accessible only within its own class. Other classes cannot access private members of a different class. - **Private(私有):** 这种修饰符使成员只能在其所属的类内访问。其他类不能访问不同类的私有成员。 @@ -361,7 +361,7 @@ class ProtectedDemo { ``` - **Public:** Public members are accessible from any class in the Java program. It provides the widest level of access. -- **Public(公共):** 公共成员可以被Java程序中的任何类访问。它提供了最广泛的访问级别。 +- **Public(公共):** 公共成员可以被 Java 程序中的任何类访问。它提供了最广泛的访问级别。 ``` public class PublicDemo { @@ -374,16 +374,16 @@ public class PublicDemo { ``` Understanding these distinctions and access levels is vital for effective Java programming, ensuring resource management, security, and encapsulation are handled appropriately in your software development endeavors. -理解这些区别和访问级别对于有效的Java编程至关重要,可以确保在软件开发过程中适当地处理资源管理、安全性和封装。 +理解这些区别和访问级别对于有效的 Java 编程至关重要,可以确保在软件开发过程中适当地处理资源管理、安全性和封装。 ## 9\. What is the Difference between an Abstract Class and an Interface? ## 9\. 抽象类和接口之间有什么区别? An abstract class in Java is used as a base for other classes. It can contain both abstract methods (without an implementation) and concrete methods (with an implementation). -在Java中,抽象类用作其他类的基类。它可以包含抽象方法(没有实现)和具体方法(有实现)。 +在 Java 中,抽象类用作其他类的基类。它可以包含抽象方法(没有实现)和具体方法(有实现)。 Abstract classes can have member variables that can be inherited by subclasses. A class can extend only one abstract class due to Java's single inheritance property. -抽象类可以有成员变量,子类可以继承这些成员变量。由于Java的单继承特性,一个类只能继承一个抽象类。 +抽象类可以有成员变量,子类可以继承这些成员变量。由于 Java 的单继承特性,一个类只能继承一个抽象类。 **Example of an Abstract Class:** **抽象类的示例:** @@ -425,10 +425,10 @@ public class Main { ``` An interface in Java, on the other hand, is a completely "abstract class" that is used to group related methods with empty bodies. -在Java中,接口则是一个完全的“抽象类”,用于将相关的方法组织在一起,这些方法只有方法签名,没有方法体。 +在 Java 中,接口则是一个完全的“抽象类”,用于将相关的方法组织在一起,这些方法只有方法签名,没有方法体。 From Java 8 onwards, interfaces can have default and static methods with a body. A class can implement any number of interfaces. -从Java 8开始,接口可以包含具有方法体的默认方法和静态方法。一个类可以实现任意数量的接口。 +从 Java 8 开始,接口可以包含具有方法体的默认方法和静态方法。一个类可以实现任意数量的接口。 **Example of an Interface:** **接口的示例:** @@ -459,29 +459,29 @@ public class Main { ``` Both abstract classes and interfaces are foundational concepts in Java, used for achieving abstraction and supporting design patterns like Strategy and Adapter. The use of these concepts depends on the specific requirements and design considerations of your software project. -抽象类和接口是Java中的基础概念,用于实现抽象和支持设计模式,如策略模式(Strategy)和适配器模式(Adapter)。这两个概念的使用取决于软件项目的具体需求和设计考虑。 +抽象类和接口是 Java 中的基础概念,用于实现抽象和支持设计模式,如策略模式(Strategy)和适配器模式(Adapter)。这两个概念的使用取决于软件项目的具体需求和设计考虑。 ![image-25](https://www.freecodecamp.org/news/content/images/2023/12/image-25.png) Luminous labyrinth depicts Java packages and threading. - [lunartech.ai][56] ## 10\. Explain the Concept of Java Packages -## 10\. 解释Java包的概念 +## 10. 解释 Java 包的概念 Java packages are a way of organizing and structuring classes and interfaces in Java applications. They provide a means to group related code together. Packages help prevent naming conflicts, enhance code readability, and facilitate code reusability. -Java包是一种组织和结构化Java应用程序中的类和接口的方式。它们提供了将相关代码分组在一起的手段。包有助于防止命名冲突,提高代码可读性,并促进代码重用。 +Java 包是一种组织和结构化 Java 应用程序中的类和接口的方式。它们提供了将相关代码分组在一起的手段。包有助于防止命名冲突,提高代码可读性,并促进代码重用。 For example, consider a banking application. You might have packages like `com.bank.accounts`, `com.bank.customers`, and `com.bank.transactions`. These packages contain classes and interfaces specific to their respective functionalities. 例如,考虑一个银行应用程序。你可能会有像 `com.bank.accounts` 、`com.bank.customers` 和 `com.bank.transactions` 这样的包。这些包包含特定功能的类和接口。 In essence, Java packages are like directories or folders in a file system, organizing code and making it more manageable. -本质上,Java包就像文件系统中的目录或文件夹,组织代码并使其更易于管理。 +本质上,Java 包就像文件系统中的目录或文件夹,组织代码并使其更易于管理。 ## 11\. What are Java Annotations? -## 11\. 什么是Java注解? +## 11. 什么是 Java 注解? Java annotations are metadata that can be added to Java source code. They provide information about the code to the compiler or runtime environment. Annotations do not directly affect the program's functionality – instead, they convey instructions to tools or frameworks. -Java注解是可以添加到Java源代码中的元数据。它们为编译器或运行时环境提供有关代码的信息。注解不会直接影响程序的功能——它们提供指令给工具或框架。 +Java 注解是可以添加到 Java 源代码中的元数据。它们为编译器或运行时环境提供有关代码的信息。注解不会直接影响程序的功能——它们提供指令给工具或框架。 A common use of annotations is for marking classes or methods as belonging to a specific framework or for providing additional information to tools like code analyzers, build tools, or even custom code generators. 注解的常见用途是标记类或方法属于特定框架,或为代码分析工具、构建工具甚至自定义代码生成器提供额外的信息。 @@ -490,16 +490,16 @@ For example, the `@Override` annotation indicates that a method is intended to o 例如,`@Override` 注解表明一个方法旨在重写超类中的方法,帮助在编译期间捕获编码错误。另一个例子是 `@Deprecated`,它表明一个方法或类不再推荐使用。 ## 12\. How Does Multi-threading Work in Java? -## 12\. Java中的多线程是如何工作的? +## 12. Java 中的多线程是如何工作的? Multi-threading in Java allows a program to execute multiple threads concurrently. Threads are lightweight processes within a program that can run independently. Java provides a rich set of APIs and built-in support for multi-threading. -Java中的多线程允许程序同时执行多个线程。线程是程序中的轻量级进程,可以独立运行。Java提供了丰富的API和内置支持来实现多线程。 +Java 中的多线程允许程序同时执行多个线程。线程是程序中的轻量级进程,可以独立运行。Java 提供了丰富的 API 和内置支持来实现多线程。 Threads in Java are typically created by either extending the `Thread` class or implementing the `Runnable` interface. Once created, threads can be started using the `start()` method, causing them to run concurrently. -Java中的线程通常通过扩展 `Thread` 类或实现 `Runnable` 接口来创建。创建线程后,可以使用 `start()` 方法启动它们,使它们并发运行。 +Java 中的线程通常通过扩展 `Thread` 类或实现 `Runnable` 接口来创建。创建线程后,可以使用 `start()` 方法启动它们,使它们并发运行。 Java's multi-threading model ensures that threads share resources like memory and CPU time efficiently while providing mechanisms like synchronization and locks to control access to shared data. -Java的多线程模型确保线程有效地共享内存和CPU时间,同时提供了如同步和锁等机制来控制对共享数据的访问。 +Java 的多线程模型确保线程有效地共享内存和 CPU 时间,同时提供了如同步和锁等机制来控制对共享数据的访问。 Multi-threading is useful for tasks such as improving application responsiveness, utilizing multi-core processors, and handling concurrent operations, as often seen in server applications. 多线程对于提高应用程序响应性、利用多核处理器以及处理并发操作(如服务器应用程序中常见的)非常有用。 @@ -508,7 +508,7 @@ Multi-threading is useful for tasks such as improving application responsiveness ## 13\. 使用 `throw` 来抛出异常 In Java programming, the `throw` keyword is crucial for handling exceptions deliberately and responsively. This approach to exception management allows developers to enforce specific conditions in their code and maintain control over the program flow. -在Java编程中,`throw` 关键字对于有意和响应性地处理异常至关重要。这种异常管理方法允许开发人员在代码中强制特定条件,并控制程序流程。 +在 Java 编程中,`throw` 关键字对于有意和响应性地处理异常至关重要。这种异常管理方法允许开发人员在代码中强制特定条件,并控制程序流程。 ```java public void verifyAge(int age) { From f0ee62a87a894330e43e2c39a6ef2c5e5d4bc00f Mon Sep 17 00:00:00 2001 From: "James Z. Zhang" <144994336+James-Z-Zhang00@users.noreply.github.com> Date: Fri, 18 Oct 2024 13:28:54 -0400 Subject: [PATCH 09/10] Update java-interview-prep-handbook.md till line 2160 --- .../articles/java-interview-prep-handbook.md | 116 +++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/chinese/articles/java-interview-prep-handbook.md b/chinese/articles/java-interview-prep-handbook.md index ac87b98d4..88aabefd4 100644 --- a/chinese/articles/java-interview-prep-handbook.md +++ b/chinese/articles/java-interview-prep-handbook.md @@ -2172,17 +2172,24 @@ public class ThreadLocalExample { ``` ### `ClassLoader` Leaks +### `ClassLoader` 泄漏 - **`ClassLoader` Lifecycle**: In environments with dynamic class loading/unloading (for example, web servers), ensure that class loaders are garbage collected when not needed. This involves ensuring that classes loaded by these class loaders are no longer referenced. +- **`ClassLoader` 生命周期**:在具有动态类加载/卸载的环境中(例如 Web 服务器),确保在不需要时垃圾回收类加载器。这涉及确保这些类加载器加载的类不再被引用。 ### Garbage Collection Tuning +### 垃圾回收调优 - **GC Analysis**: Analyze GC logs to understand the garbage collection behavior and identify potential memory leaks. - **GC Algorithm Choice**: Choose an appropriate garbage collection algorithm based on application needs, which can be tuned with JVM options for optimal performance. +- **GC 分析**:分析 GC 日志以了解垃圾回收的行为,并识别潜在的内存泄漏。 +- **GC 算法选择**:根据应用程序的需求选择合适的垃圾回收算法,并通过 JVM 选项进行调优,以实现最佳性能。 ### String Interning +### 字符串驻留 - **Selective Interning**: Be cautious with the `String.intern()` method. Unnecessary interning of strings can lead to a bloated String pool. +- **选择性驻留**:谨慎使用 `String.intern()` 方法。不必要的字符串驻留会导致字符串池膨胀。 ``` public class StringInterningExample { @@ -2196,7 +2203,12 @@ public class StringInterningExample { Utilize tools like SonarQube, FindBugs, or PMD to statically analyze code for patterns that could lead to memory leaks. +### 静态分析工具 + +使用像 SonarQube、FindBugs 或 PMD 这样的工具,静态分析代码中的可能导致内存泄漏的模式。 + ### Developer Training and Code Reviews +### 开发者培训和代码审查 Regularly train developers on best practices in memory management and conduct thorough code reviews with a focus on potential memory leak patterns. @@ -2204,15 +2216,28 @@ Memory leak prevention in Java is a sophisticated practice that involves a thoro By adopting these advanced practices, developers can significantly mitigate the risk of memory leaks, leading to more robust, efficient, and scalable Java applications. +定期对开发者进行内存管理最佳实践的培训,并进行详细的代码审查,重点关注潜在的内存泄漏模式。 + +在 Java 中,防止内存泄漏是一项复杂的实践,涉及对 Java 内存管理的深入理解、细致的编码、谨慎使用分析工具以及定期监控。 + +通过采用这些高级实践,开发者可以大大降低内存泄漏的风险,进而开发出更健壮、高效和可扩展的 Java 应用程序。 + ## 49\. Explain the Purpose of Java's Synchronized Block +## 49\. 解释 Java 同步块的用途 The purpose of Java's synchronized block is to ensure thread safety in concurrent programming by controlling access to a shared resource among multiple threads. In a multithreaded environment, where multiple threads operate on the same object, there's a risk of data inconsistency if the threads simultaneously modify the object. A synchronized block in Java is used to lock an object for exclusive access by a single thread. +Java 同步块的用途是在并发编程中通过控制多个线程对共享资源的访问来确保线程安全。 + +在多线程环境中,当多个线程对同一个对象进行操作时,如果线程同时修改该对象,会存在数据不一致的风险。Java 中的同步块用于锁定一个对象,以便单个线程独占访问。 + ### Thread Safety and Data Consistency +### 线程安全和数据一致性 When different threads access and modify shared data, it can lead to unpredictable data states and inconsistencies. The synchronized block ensures that only one thread can execute a particular block of code at a time, thus maintaining data integrity. +当不同的线程访问和修改共享数据时,可能会导致数据状态不可预测和不一致。同步块确保一次只有一个线程可以执行特定的代码块,从而维护数据的完整性。 ``` public class Counter { @@ -2237,6 +2262,10 @@ public class Counter { In Java, each object has an intrinsic lock or monitor lock. When a thread enters a synchronized block, it acquires the lock on the specified object. Other threads attempting to enter the synchronized block on the same object are blocked until the thread inside the synchronized block exits, thereby releasing the lock. +### 锁机制 + +在 Java 中,每个对象都有一个内在锁或监视器锁。当一个线程进入同步块时,它会获取指定对象的锁。其他试图进入相同对象同步块的线程将被阻塞,直到同步块内的线程退出并释放锁。 + ``` public class SharedResource { private final Object lock = new Object(); @@ -2256,6 +2285,10 @@ public class SharedResource { The synchronized block is defined within a method, and you must specify the object that provides the lock: +### 语法与用法 + +同步块在方法内部定义,你必须指定提供锁的对象: + ``` public class SynchronizedBlockExample { private final Object lockObject = new Object(); @@ -2278,6 +2311,14 @@ Compared to synchronized methods, synchronized blocks provide finer control over While a synchronized method locks the entire method, a synchronized block can lock only the part of the method that needs synchronization, potentially improving performance. +`lockObject` 是对同步块获取的锁对象的引用。它可以是 `this`,用于锁定当前对象,或者是类对象用于类级别的锁,也可以是其他任何对象。 + +### 相较于同步方法的优势 + +与同步方法相比,同步块在锁的范围和持续时间上提供了更精细的控制。 + +同步方法锁定整个方法,而同步块只锁定需要同步的部分代码,从而可能提高性能 + ``` public class MethodVsBlockSynchronization { private int sharedState; @@ -2301,6 +2342,10 @@ public class MethodVsBlockSynchronization { Take care to avoid deadlocks, a situation where two or more threads are blocked forever, each waiting for the other's lock. This usually occurs when multiple synchronized blocks are locking objects in an inconsistent order. +### 避免死锁 + +注意避免死锁,这是一个情况:两个或多个线程被永久阻塞,每个线程都在等待对方的锁。通常发生在多个同步块以不一致的顺序锁定对象时。 + ``` public class DeadlockAvoidanceExample { private final Object lock1 = new Object(); @@ -2334,6 +2379,10 @@ public class DeadlockAvoidanceExample { Synchronized blocks also solve memory visibility problems. Changes made by one thread in a synchronized block are visible to other threads entering subsequent synchronized blocks on the same object. +### 内存可见性 + +同步块还解决了内存可见性问题。一个线程在同步块中所做的更改对于进入同一对象后续同步块的其他线程是可见的。 + ``` public class MemoryVisibility { private volatile boolean flag = false; @@ -2363,23 +2412,48 @@ public class MemoryVisibility { - **Avoid Locking on Public Objects**: Locking on public objects can lead to accidental and uncontrolled access to the lock, increasing the deadlock risk. Prefer private objects as lock targets. - **Complement with Other Concurrency Tools**: In some cases, using higher-level concurrency tools like `ReentrantLock`, `Semaphore`, or concurrent collections from `java.util.concurrent` package might be more appropriate. +### 最佳实践 + +- 最小化锁竞争:尽量保持同步块的时间尽可能短,以最小化锁竞争,避免性能瓶颈。 +- 一致的锁定顺序:始终以一致的顺序获取锁,以防止死锁。 +- 避免锁定公共对象:锁定公共对象可能导致意外和无法控制的访问锁,从而增加死锁的风险。建议将私有对象作为锁的目标。 +- 与其他并发工具配合使用:在某些情况下,使用更高级别的并发工具,如 ReentrantLock、Semaphore 或来自 java.util.concurrent 包的并发集合可能更合适。 + Java's synchronized block is a critical tool for achieving thread safety in concurrent applications. Its proper use ensures data integrity and consistency by controlling access to shared resources. But, it requires careful consideration to avoid common pitfalls like deadlocks and performance issues due to excessive lock contention. +Java 的同步块是实现并发应用程序线程安全的关键工具。其正确使用通过控制对共享资源的访问来确保数据完整性和一致性。但它需要仔细考虑,以避免诸如死锁和因过度锁竞争导致的性能问题等常见陷阱。 + + Understanding and applying these concepts is essential for developers working in a multithreaded environment to create robust and efficient Java applications. +理解并应用这些概念对开发人员在多线程环境下创建健壮且高效的 Java 应用程序至关重要。 + ## 50\. Explain the Concept of Modules in Java Modules in Java, introduced in Java 9 with the Java Platform Module System (JPMS), represent a fundamental shift in organizing Java applications and their dependencies. Understanding modules is essential for modern Java development, as they offer improved encapsulation, reliable configuration, and scalable system architectures. +## 50. 解释 Java 模块的概念 + +Java 模块是在 Java 9 中引入的 Java 平台模块系统(JPMS),代表了组织 Java 应用程序及其依赖项的根本性转变。 + +理解模块对于现代 Java 开发至关重要,因为它们提供了更好的封装、可靠的配置以及可扩展的系统架构。 + #### What are Java modules? A module in Java is a self-contained unit of code and data, with well-defined interfaces for communicating with other modules. Each module explicitly declares its dependencies on other modules. Modules enable better encapsulation by allowing a module to expose only those parts of its API which should be accessible to other modules, while keeping the rest of its codebase hidden. This reduces the risk of unintended usage of internal APIs. +#### 什么是 Java 模块? + +Java 中的模块是一个自包含的代码和数据单元,具有与其他模块通信的明确接口。每个模块明确声明它对其他模块的依赖关系。 + +模块通过允许一个模块仅公开其 API 中应被其他模块访问的部分,同时隐藏其其余代码库,从而实现更好的封装。这减少了内部 API 被意外使用的风险。 + #### Key Components of modules +#### 模块的关键组件 **`module-info.java`:** Each module must have a `module-info.java` file at its root, which declares the module's name, its required dependencies, and the packages it exports. @@ -2391,7 +2465,9 @@ module com.example.myapp { ``` 1. Here, `com.example.myapp` is the module name, `java.sql` is a required module, and `com.example.myapp.api` is the exported package. +1. 在这里,`com.example.myapp` 是模块名称,`java.sql` 是所需模块,`com.example.myapp.api` 是导出的包。 2. **Exports and Requires:** The `exports` keyword specifies which packages are accessible to other modules, while `requires` lists the modules on which the current module depends. +2. **导出和依赖:** `exports` 关键字指定了哪些包可以被其他模块访问,而 `requires` 列出了当前模块依赖的模块。 #### Benefits @@ -2399,10 +2475,19 @@ module com.example.myapp { 2. **Reduced Memory Footprint:** By only loading the required modules, applications can reduce their memory footprint and start-up time, enhancing performance. 3. **Enhanced Security and Maintenance:** Modules reduce the surface area for potential security vulnerabilities. They also simplify dependency management, making it easier to update and maintain libraries without affecting the entire system. +#### 优点 +1. 改善应用程序结构: 模块鼓励更清晰、组织更合理的代码结构,帮助维护大型代码库并提高代码质量。 +2. 减少内存占用: 通过仅加载所需的模块,应用程序可以减少内存占用和启动时间,从而提升性能。 +3. 增强安全性和维护性: 模块减少了潜在安全漏洞的暴露面。它们还简化了依赖管理,使得更新和维护库变得更容易,而不会影响整个系统。 + #### Practical Example Consider a scenario where you are developing a large-scale application with various functionalities like user management, data processing, and reporting. By organizing these functionalities into separate modules (like `usermodule`, `dataprocessmodule`, `reportmodule`), you can maintain them independently, avoiding the complexities of a monolithic application structure. +#### 实用示例 + +考虑一个场景,你正在开发一个具有多种功能的大型应用程序,例如用户管理、数据处理和报告。通过将这些功能组织到单独的模块中(如 `usermodule`、`dataprocessmodule`、`reportmodule`),你可以独立维护它们,避免单一应用程序结构的复杂性。 + ``` // In module-info.java of usermodule module usermodule { @@ -2424,63 +2509,89 @@ module reportmodule { ``` Modules in Java are a powerful feature for building scalable, maintainable, and efficient applications. They offer clear boundaries and contracts between different parts of a system, facilitating better design and architecture. +Java 中的模块是构建可扩展、可维护和高效应用程序的强大功能。它们为系统的不同部分提供了清晰的边界和契约,从而促进了更好的设计和架构。 For developers and teams aiming to build robust Java applications, understanding and leveraging modules is not just a technical skill but a strategic approach to software development. +对于希望构建强大 Java 应用程序的开发人员和团队来说,理解和利用模块不仅仅是一项技术技能,更是软件开发的一种战略方法。 This modular architecture aligns with modern development practices, enabling Java applications to be more scalable and easier to manage in the long term. +这种模块化架构与现代开发实践相一致,使 Java 应用程序在长期内更具可扩展性并且更容易管理。 ![image-34](https://www.freecodecamp.org/news/content/images/2023/12/image-34.png) ## Conclusion +## 结论 As we wrap up this roundup of Java interview questions, I want to take a moment to thank the freeCodeCamp team. This platform is a fantastic resource for people learning to code, and it's great to have such a supportive community in the tech world. +在我们结束这次 Java 面试问题的总结时,我想花一点时间感谢 freeCodeCamp 团队。这个平台是学习编程的绝佳资源,在技术界拥有如此支持的社区真是太好了。 I also want to thank the editorial team for their help in making this guide possible. Working together has been a great experience, and it's been rewarding to combine our efforts to help others learn Java. +我还要感谢编辑团队,他们为这本指南的成功提供了很大帮助。合作的过程非常愉快,结合我们的努力帮助他人学习 Java 是一件令人倍感成就的事情。 It's important to reflect on the journey we've undertaken together. Java's robustness in Object-Oriented Programming (OOP) is a critical asset for developers at all levels, especially those aspiring to join top-tier tech firms. This handbook has aimed to provide a clear pathway to mastering Java interviews, focusing on the insights and techniques that matter most in the competitive landscape of big tech. +重要的是,反思我们共同进行的这段旅程。Java 在面向对象编程(OOP)中的稳健性是所有级别开发人员的重要资产,尤其是那些希望加入顶级科技公司的开发人员。本手册旨在为掌握 Java 面试提供清晰的路径,重点关注在大科技公司竞争激烈的环境中最重要的见解和技巧。 From the fundamentals to the more complex aspects of Java, I've sought to bridge the gap between basic Java knowledge and the sophisticated expertise that industry leaders like Google value. This resource is crafted not just for those new to Java, but also for those revisiting key concepts, offering a comprehensive understanding of the language in a practical context. +从基础知识到 Java 的更复杂方面,我力求弥合基础 Java 知识与行业领袖(如 Google)所看重的专业技能之间的差距。这本资源不仅为初学者设计,也为那些回顾关键概念的开发人员提供了实践上下文中的全面理解。 As you continue to explore the depths of Java, remember that mastering this language is not just about enhancing coding skills, but also about expanding your professional horizons. Java's significant role in IoT and its presence in billions of devices worldwide make it a language that can truly shape your career. +当你继续深入探索 Java 时,记住掌握这门语言不仅是提高编码技能的过程,也是扩展职业视野的机会。Java 在物联网(IoT)中的重要性以及其在全球数十亿设备中的广泛应用,使得它成为一门真正能够塑造你职业生涯的语言。 In closing, I hope this handbook has provided you with valuable insights and a strong foundation for your future endeavors in Java programming and beyond. Whether you're preparing for a big tech interview or simply looking to refine your software development skills, this guide is a stepping stone towards achieving those goals. +最后,我希望这本手册为你提供了有价值的见解,并为你未来在 Java 编程及其他方面的努力奠定了坚实的基础。无论你是在准备顶级科技公司的面试,还是仅仅想提高你的软件开发技能,这本指南都将是你实现这些目标的跳板。 ## Resources +## 资源 If you're keen on furthering your Java knowledge, here's a guide to help you [conquer Java and launch your coding career][64]. It's perfect for those interested in AI and machine learning, focusing on effective use of data structures in coding. This comprehensive program covers essential data structures, algorithms, and includes mentorship and career support. +如果你有兴趣进一步深入学习 Java,这里有一份指南可以帮助你 [征服 Java 并启动你的编程职业生涯][64]。它特别适合对人工智能和机器学习感兴趣的学习者,专注于有效使用数据结构进行编码。这一全面的课程涵盖了数据结构、算法,并提供了导师和职业支持。 Additionally, for more practice in data structures, you can explore these resources: +此外,为了更多地练习数据结构,你可以探索以下资源: 1. ****[Java Data Structures Mastery - Ace the Coding Interview][65]****: A free eBook to advance your Java skills, focusing on data structures for enhancing interview and professional skills. +1. [Java 数据结构精通 - 面试通关秘籍][65]: 一本免费电子书,帮助你提升 Java 技能,专注于提高面试和专业技能所需的数据结构。 2. [****Foundations of Java Data Structures - Your Coding Catalyst****:][66] Another free eBook, diving into Java essentials, object-oriented programming, and AI applications. +2. [Java 数据结构基础 - 你的编码催化剂:][66] 另一部免费电子书,深入探讨 Java 的基础知识,面向对象编程及其在 AI 中的应用。 Visit LunarTech's website for these resources and more information on the [bootcamp][67]. +访问 LunarTech 网站以获取这些资源和更多关于 [训练营][67] 的信息。 ### ******Connect with Me****** +### ******联系我****** - [Follow me on LinkedIn for a ton of Free Resources in CS, ML and AI][68] +- [关注我 LinkedIn,获取大量计算机科学、机器学习和人工智能的免费资源][68] - [Visit my Personal Website][69] +- [访问我的个人网站][69] - Subscribe to my [The Data Science and AI Newsletter][70] +- 订阅我的 [数据科学与人工智能通讯][70] ### **About the Author** +### **关于作者** I'm Vahe Aslanyan, deeply engaged in the intersecting worlds of computer science, data science, and AI. I invite you to explore my portfolio at vaheaslanyan.com, where I showcase my journey in these fields. My work focuses on blending full-stack development with AI product optimization, all fueled by a passion for innovative problem-solving. +我是 Vahe Aslanyan,深深参与在计算机科学、数据科学和人工智能的交汇领域。我邀请你访问我的个人网站 vaheaslanyan.com,在那里我展示了我在这些领域的旅程。我的工作重点是将全栈开发与 AI 产品优化相结合,驱动创新问题的解决。 [ Vahe Aslanyan - Crafting Code, Shaping Futures +Vahe Aslanyan - 打造代码,塑造未来 Dive into Vahe Aslanyan’s digital world, where each endeavor offers new insights and every hurdle paves the way for growth. +深入 Vahe Aslanyan 的数字世界,每一次探索都提供了新的见解,每一个障碍都铺平了增长的道路。 -![6539302e3cd34bb5cbabe5f9_Vahe%20Aslanyan%20(256%20x%20256%20px)](https://assets-global.website-files.com/64f8c178a66a6e1a607ff9d0/6539302e3cd34bb5cbabe5f9_Vahe%20Aslanyan%20(256%20x%20256%20px).png)Crafting Code, Shaping Futures +![6539302e3cd34bb5cbabe5f9_Vahe%20Aslanyan%20(256%20x%20256%20px)](https://assets-global.website-files.com/64f8c178a66a6e1a607ff9d0/6539302e3cd34bb5cbabe5f9_Vahe%20Aslanyan%20(256%20x%20256%20px).png)Crafting Code, Shaping Futures 打造代码,塑造未来 ![Ntarl3h](https://i.imgur.com/Ntarl3h.png) ][71] I've had the privilege of contributing to the launch of a well-regarded data science bootcamp and collaborating with some of the best minds in the industry. My goal has always been to raise the bar in tech education, making it accessible and standard for everyone. +我有幸为启动一门备受好评的数据科学训练营作出了贡献,并与行业中的顶尖人才合作。我的目标一直是提高技术教育的标准,并使其对所有人都更具包容性和可及性。 As we conclude our journey here, I want to thank you for your time and engagement. Sharing my professional and academic experiences in this book has been a rewarding experience. I appreciate your involvement and look forward to seeing how it helps you advance in the tech world. +在我们结束此次旅程时,我想感谢你花费的时间和参与。在这本书中分享我的专业和学术经验是一件令人满意的事情。我感谢你的参与,并期待看到它如何帮助你在技术世界中前进。 --- @@ -2489,12 +2600,15 @@ As we conclude our journey here, I want to thank you for your time and engagemen [Vahe Aslanyan][72] I'm Vahe Aslanyan, dedicated to making AI and data science education inclusive and accessible. I guide developers towards clear tech understanding in software engineering. +我是 Vahe Aslanyan,致力于使 AI 和数据科学教育更加包容和可访问。我引导开发人员深入理解软件工程中的技术。 --- If you read this far, thank the author to show them you care. Say Thanks +如果你读到这里,请向作者表达感谢,告诉他们你关心。说声谢谢吧。 Learn to code for free. freeCodeCamp's open source curriculum has helped more than 40,000 people get jobs as developers. [Get started][73] +免费学习编程。freeCodeCamp 的开源课程已经帮助超过 40,000 人获得开发者职位。 [开始学习][73] [1]: /news/tag/java/ [2]: /news/author/vahe/ From 01614cb5e2d20537f5f5136114e84c66d1810a7a Mon Sep 17 00:00:00 2001 From: James-Z-Zhang00 Date: Fri, 18 Oct 2024 17:29:52 +0000 Subject: [PATCH 10/10] Auto Format --- chinese/articles/coding-bootcamp-handbook.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/chinese/articles/coding-bootcamp-handbook.md b/chinese/articles/coding-bootcamp-handbook.md index 62d9aff9b..d6766fa51 100644 --- a/chinese/articles/coding-bootcamp-handbook.md +++ b/chinese/articles/coding-bootcamp-handbook.md @@ -389,7 +389,7 @@ Surprisingly, there are a few bootcamps that are for-profit but still free. And 要了解参加编码训练营的真实成本,你应该考虑机会成本。 -**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 +**例子**:你现在每个月赚$3000美元。你搬到旧金山,在那$2,000 美元只能租到一个卧室。你参加 12 周的训练营费用是\$15,00 0美元。 这是你的真实成本,假设加上你在 6 个月的时间内找到工作并领取第一份薪水: