TAILIEUCHUNG - Java All-in-One Desk Reference For Dummies phần 6

Vì vậy, một lớp bên trong có thể truy cập nhiều lớp bên ngoài của nó hơn là một lớp con đã siêu lớp của nó. (Một phân lớp có thể truy cập các thành viên công cộng và bảo vệ của siêu lớp của nó, nhưng không phải là thành viên tư nhân.) ✦ Một lớp bên trong mang theo nó một tham chiếu đến các trường hợp hiện tại của các lớp bên ngoài | Chapter 5 Creating Generic Collection Classes ỉn This Chapter Discovering why the generics feature was invented Using generics in your own classes Working with wildcards in a generic class Examining a pair of classes that demonstrate generics f . . . . n the previous two chapters you ve seen how you can specify the type for an ArrayList or a LinkedList so the compiler can prevent you from accidentally adding the wrong type of data to the collection. The ArrayList and LinkedList classes are able to do this because they take advantage of a new feature of Java called generics. In this chapter I show you how the generics feature works and how to put it to use in your own classes. Specifically you see examples of two classes that use the LinkedList class to implement a specific kind of collection. The first is a stack a collection in which items are always added to the front of the list and retrieved from the front of the list. The second is a queue a collection in which items are added to the end of the list and retrieved from the front. This is one of those chapters where the entire chapter gets a Technical Stuff icon. Frankly generics is on the leading edge of object-oriented programming. You can get by without knowing any of the information in this chapter so feel free to skip it if you re on your way to something more interesting. However this chapter is worth looking at even if you just want to get an idea of how the ArrayList and LinkedList classes use the new generics feature. And you might find that someday you want to create your own generic classes. Your friends will surely think you re a genius. To be sure I won t be covering all the intricacies of programming with generics. If your next job happens to be writing Java class libraries for Sun you ll need to know a lot more about generics than this chapter covers. I focus just on the basics of writing simple generic classes. 420 Why Generics Why Generics Before Java collection classes could hold any .

TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.