Nó dạy cho bạn 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 4 đã không chỉ được tacked vào các chương từ trước NET 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 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 arguments Examples double subtotal get a double entry from the console String currentDate I convert the date to a string How to call a static method from a class Syntax arguments Examples string sPrỉce price convert a double to a string double total 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 66 Section 1 Essential Java skills How to use the API .