This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes awt - toolkit method().method() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "awt - toolkit method().method()" Watch "awt - toolkit method().method()" New topic
Author

awt - toolkit method().method()

srinivas bolloju
Ranch Hand

Joined: Jan 23, 2001
Posts: 112
im little confused..
a class contains 2 methods...for ex..lets take Toolkit class in awt package...it constains 2 methods, what does it mean when u write class.method1().method2()
method2() is returning something
method1() is returning something else...
for ex..in the below statement...
x=Toolkit.getDefaultToolkit().getImage"MyPicture.jpg");


please use the [code][/code] tags when showing code. visit <a href="http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page" target="_blank" rel="nofollow">http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=ubb_code_page</a> ,for more details
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
you're just invoking two methods. For example Say I had variable of type String:
String a;
And I wanted to get 4.5 rounded.
I would simply say:
a= Math.round(4.5).toString();
In this example the number 4.5 is rounded, and then that number is converted to a string. Do you get it?
srinivas bolloju
Ranch Hand

Joined: Jan 23, 2001
Posts: 112
hi sean i got it,but this raises some more doubts....
1)
can we link any no.of.methods like this fashion....
x= class.method1().method2().method3().method4().....or is there any constraint for it.....and
2)
if 1) above is true, is it evaluated like....
class.{{{{method1()}.method2()}.method3()}.method4()}
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
I think you'd be better off if you start coding these things yourself, and testing them. You tell me if you can do that.
srinivas bolloju
Ranch Hand

Joined: Jan 23, 2001
Posts: 112
thanx anyway sean
Sean Casey
Ranch Hand

Joined: Dec 16, 2000
Posts: 625
I'm still willing to help,I just think you'd get more out of it if you tried it out yourself.
to answer you question you can chain methods as long as it makes sense.
For example I couldn't do the following:
int a= (int)math.round(5553.234343).repaint();
Obviously repaint() doesn't belong there, but you see what I mean. Right?
 
jQuery in Action, 2nd edition
 
subject: awt - toolkit method().method()
 
Similar Threads
Thread synchronization
Need Help on More Anonymous Classes
loading an image
How to find out where an Exception was thrown ?
synchronized method(s) purpose