Đang chuẩn bị liên kết để tải về tài liệu:
murachs Java SE 2010 phần 2
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Nó dạy cho bạn ASP.NET 4 tính năng khi họ đang thích hợp, không chỉ thuận tiện Ngược lại một số cuốn sách, các tính năng ASP.NET 4 đã không chỉ được tacked vào các chương từ trước NET 3.5 phiên bản. | Chapter 2 Introduction to Java programming 65 How to create an object from a class Syntax ClassName objectName new ClassName arguments Examples Scanner sc new Scanner System.ỉn creates a Scanner object named sc Date now new DateO creates a Date object named now How to call a method from an object Syntax objectName.methodName arguments Examples double subtotal sc.nextDouble0 get a double entry from the console String currentDate now.toString0 I convert the date to a string How to call a static method from a class Syntax ClassName.methodName arguments Examples string sPrỉce Double.toString price convert a double to a string double total Double.parseDouble userEntry convert a string to a double Description When you create an object from a Java class you are creating an instance of the class. Then you can use the methods of the class by calling them from the object. Some Java classes contain static methods. These methods can be called dfrectly from the class without creating an object. When you create an object from a class the constructor may require one or more arguments. These arguments must have the required data types and they must be coded in the correct sequence separated by commas. When you call a method from an object or a class the method may requfre one or more arguments. Here again these arguments must have the required data types and they must be coded in the correct sequence separated by commas. Although you can use the syntax shown in this figure to create a String object the syntax in figure 2-7 is the preferred way to do that. Once a String object is created though you call its methods from the object as shown above. In this book you ll learn how to use dozens of the Java classes and methods that you ll use the most in your applications. You will also learn how to create your own classes and methods. Figure 2-10 How to create objects and call methods Download from Wow eBook www.wowebook.com 66 Section 1 Essential Java skills How to use the API .