class Point(xc: Int, yc: Int) {
var x: Int = xc
var y: Int = yc
def move(dx: Int, dy: Int) {
x = x + dx
y = y + dy
}
override def toString(): String = "(" + x + ", " + y + ")";
}
以上定义了类point,其中有2个变量x,y,两个方法move(),toString().
move():没有返回值,相当于JAVA中的void类型,这里隐式继承了unit类。