The Java Tutorials have been written for JDK 8.Java教程是为JDK 8编写的。Examples and practices described in this page don't take advantage of improvements introduced in later releases and might use technology no longer available.本页中描述的示例和实践没有利用后续版本中引入的改进,并且可能使用不再可用的技术。See Java Language Changes for a summary of updated language features in Java SE 9 and subsequent releases.有关Java SE 9及其后续版本中更新的语言特性的摘要,请参阅Java语言更改。
See JDK Release Notes for information about new features, enhancements, and removed or deprecated options for all JDK releases.有关所有JDK版本的新功能、增强功能以及已删除或不推荐的选项的信息,请参阅JDK发行说明。
What's wrong with the following program?以下程序有什么问题?
public class SomethingIsWrong { public static void main(String[] args) { Rectangle myRect; myRect.width = 40; myRect.height = 50; System.out.println("myRect's area is " + myRect.area()); } }
The following code creates one array and one string object.下面的代码创建一个数组和一个字符串对象。How many references to those objects exist after the code executes?代码执行后,存在多少对这些对象的引用?Is either object eligible for garbage collection?这两个对象都有资格进行垃圾收集吗?
... String[] students = new String[10]; String studentName = "Peter Parker"; students[0] = studentName; studentName = null; ...
How does a program destroy an object that it creates?程序如何销毁它创建的对象?
Fix the program called 修复问题1中显示的名为SomethingIsWrong
shown in Question 1.SomethingIsWrong
的程序。
Given the following class, called NumberHolder, write some code that creates an instance of the class, initializes its two member variables, and then displays the value of each member variable.给定以下名为NumberHolder的类,编写一些代码来创建该类的实例,初始化其两个成员变量,然后显示每个成员变量的值。
public class NumberHolder { public int anInt; public float aFloat; }