View Single Post
  #4 (permalink)  
Old 11-21-2007, 12:07 AM
hardwired hardwired is offline
Senior Member
 
Join Date: Jul 2007
Posts: 1,222
hardwired is on a distinguished road
Code:
Relatable r1 = new Length(12); Relatable r2 = new Length(32); System.out.println("r1.isLargerThan(r2) = " + r1.isLargerThan(r2));
we can call a method only with class object.is this right
Yes...
Call instance methods with instance variable:
Rectangle rect = new Rectangle(25, 25);
int w = rect.getWidth();
Call static (class) methods with ClassName:
double distance = Point2D.distance(x1, y1, x2, y2);
Reply With Quote