TAILIEUCHUNG - Sams Teach Yourself Java 6 in 21 Days 5th phần 3

Như bạn đã học được, Java cung cấp lớp wrapper như Integer và Float cho mỗi của các loại nguyên thủy. Bằng cách sử dụng phương pháp lớp được định nghĩa trong những lớp học, bạn có thể chuyển các đối tượng các loại nguyên thủy và chuyển đổi các loại nguyên thủy cho các đối tượng. | 124 SimpoEPDF Mergeand Split Unregistered Version - http As you have learned Java supplies wrapper classes such as Integer and Float for each of the primitive types. By using class methods defined in those classes you can convert objects to primitive types and convert primitive types to objects. For example the parseInt class method in the Integer class can be used with a string argument returning an int representation of that string. The following statement shows how the parseInt method can be used int count 42 In the preceding statement the String value 42 is returned by parseInt as an integer with a value of 42 and this is stored in the count variable. The lack of a static keyword in front of a method name makes it an instance method. Instance methods operate in a particular object rather than a class of objects. On Day 1 Getting Started with Java you created an instance method called checkTemperature that checked the temperature in the robot s environment. TIP Most methods that affect a particular object should be defined as instance methods. Methods that provide some general capability but do not directly affect an instance of the class should be declared as class methods. Creating Java Applications Now that you know how to create classes objects class and instance variables and class and instance methods you can put it all together in a Java program. To refresh your memory applications are Java classes that can be run on their own. NOTE Applications are different from applets which are run by a Java-enabled browser as part of a web page. You can find out how to develop applets in Writing Java Applets a bonus chapter included on this book s CD. A Java application consists of one or more classes and can be as large or as small as you want it to be. Although all the applications you ve created up to this point do nothing but output some characters to the screen you also can create Java applications that use windows graphics and

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.