X hits on this document

126 views

0 shares

0 downloads

0 comments

23 / 46

© S. Uchitel, 2004

23

Accessing methods and fields

Given a reference to an object we can access its fields and methods using the dot operator.

<object reference>.<field name>

<object reference>.<method call>

<<instanceOf>>

Circle

colour:String

diameter:double

perimeter():double

area():double

myCircle:Circle

colour = “red”

diameter = 2

perimeter():double

area():double

Circle myCircle = new Circle(“red”, 2);

System.out.println(myCircle.area());

Document info
Document views126
Page views126
Page last viewedSun Dec 11 03:06:19 UTC 2016
Pages46
Paragraphs816
Words2901

Comments