X hits on this document

152 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 views152
Page views152
Page last viewedSat Jan 21 00:18:50 UTC 2017
Pages46
Paragraphs816
Words2901

Comments