TAILIEUCHUNG - Java™ How to Program ( Deitel - Deitel) - Phần 15

Tham khảo sách 'java™ how to program ( deitel - deitel) - phần 15', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | PREY NEXT Page 385 . static Import In Section you learned about the static fields and methods of class Math. We invoked class Math s static fields and methods by preceding each with the class name Math and a dot . . A static import declaration a new feature of J2SE enables programmers to refer to imported static members as if they were declared in the class that uses themthe class name and a dot . are not required to use an imported static member. A static import declaration has two formsone that imports a particular static member which is known as single static import and one that imports all static members of a class which is known as static import on demand . The following syntax imports a particular static member import static packageName. where packageName is the package of the class . ClassName is the name of the class . Math and staticMemberName is the name of the static field or method . pi or abs . The following syntax imports all static members of a class import static . where packageName is the package of the class . and ClassName is the name of the class . Math . The asterisk indicates that all static members of the specified class should be available for use in the class es declared in the file. Note that static import declarations import only static class members. Regular import statements should be used to specify the classes used in a program. Figure demonstrates a static import. Line 3 is a static import declaration that imports all static fields and methods of class Math from package . Lines 912 access the Math class s static field e line 11 and the static methods sqrt line 9 ceil line 10 log line 11 and cos line 12 without preceding the field name or method names with class name Math and a dot. Figure . Static import Math methods. 1 Fig. 2 Using static import to import static methods of class Math. 3 import .

TỪ KHÓA LIÊN QUAN
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.