tailieunhanh - Chapter 7 Quick Reference

Chương 7 Quick tham khảo để làm lớp học này từ khóa Viết, theo sau là tên của lớp, tiếp theo là một cú đúp mở và đóng cửa. Các phương pháp và các lĩnh vực của lớp được khai báo giữa mở và đóng cú đúp. | Chapter 7 Quick Reference To Do this Write the keyword class followed by the name of the class followed by an opening and closing brace. The methods and fields of the class are declared between the opening and closing brace. For example Declare a class class Point . Write a method whose name is the same as the name of the class and that has no return type not even void . For example class Point Declare a constructor public Point int x int y . Use the new keyword and specify the constructor with an appropriate set Call a of parameters. For example constructor Point origin new Point 0 0 Write the keyword static before the declaration of the method. For example class Point Declare a static method public static int ObjectCount . Write the name of the class followed by a period followed by the name of Call a static the method. For example method int pointsCreatedSoFar Declare a Write the keyword static before the declaration of the field. For example static field To Do this class Point private static int objectCount Write the keyword const before the declaration of the field and omit the static keyword For example Declare a class Math const field . public const double PI . Write the name of the class followed by a period followed by the name of Access a the static field. For example static field double area radius radius