Chapter 7 Quick Reference - Pdf 68



Chapter 7 Quick Reference
To Do this
Declare a
class
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:
class Point
{
...
}
Declare a
constructor
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
{
public Point(int x, int y)
{
...
}
}
Call a
constructor
Use the new keyword, and specify the constructor with an appropriate set
of parameters. For example:
Point origin = new Point(0, 0);
Declare a
static method

public const double PI = ...;
}
Access a
static field
Write the name of the class, followed by a period, followed by the name of
the static field. For example:
double area = Math.PI * radius * radius;


Nhờ tải bản gốc

Tài liệu, ebook tham khảo khác

Music ♫

Copyright: Tài liệu đại học © DMCA.com Protection Status