java software solutions foundations of program design 4th edition phần 4

Cuốn sách này là viết phần mềm được thiết kế tốt. Để hiểu phần mềm, trước tiên chúng ta phải có một sự hiểu biết cơ bản về vai trò của nótrong một hệ thống máy tính. Phần cứng và phần mềm hợp tác trong một hệ thống máy tính để thực hiện các nhiệm vụ phức tạp. | references revisited 275 parameter. Therefore the following expression returns true if both references refer to the same object bishop2 However we could define the equals method in the Chesspiece class to define equality for Chesspiece objects any way we would like. That is we could define the equals method to return true under whatever conditions we think are appropriate to mean that one Chesspiece is equal to another. As we discussed in Chapter 3 the equals method has been given an appropriate definition in the String class. When comparing two String objects the equals method returns true only if both strings contain the same characters. A common mistake is to use the operator to compare strings which compares the references for equality when most of the time we want to compare the characters inside the string objects for equality. We discuss the equals method in more detail in Chapter 7. The equals method can be defined to determine equality between objects in any way we consider appropriate. garbage collection All interaction with an object occurs through a reference variable so we can use an object only if we have a reference to it. When all references to an object are lost perhaps by reassignment that object can no longer participate in the program. The program can no longer invoke its methods or use its variables. At this point the object is called garbage because it serves no useful purpose. Java performs automatic garbage collection. When the last reference to an object is lost the object becomes a candidate for garbage collection. Occasionally the Java runtime executes a method that collects all of the objects marked for garbage collection and returns their allocated memory to the system for future use. The programmer does not have to worry about explicitly returning memory that has become garbage. If there is an activity that a programmer wants to accomplish in conjunction with the object being destroyed the programmer can define a .

Bấm vào đây để xem trước nội dung
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
77    128    2    30-04-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.