aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Cryptic java declaration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Cryptic java declaration" Watch "Cryptic java declaration" New topic
Author

Cryptic java declaration

vi ch
Greenhorn

Joined: Jan 09, 2002
Posts: 3
Hi,
Can anyone explain the statement
Fruit lime, kumqat=new Fruit(), raspberry;
Thanks
Vidyu
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Sure,
Fruit lime, kumqat=new Fruit(), raspberry;
declares three reference variables of type Fruit, lime, kumqat and raspberry. Only kumqat gets initialized (new Fruit()). The statement is the same as the three following:
Fruit lime;
Fruit kumqat = new Fruit();
Fruit raspberry;
You can declare (and initialize) several references of the same type on the same line, just separate them by commas.
We would like you to read the Javaranch Naming Policy and register again.
Thank you for your cooperation
HIH
[ January 17, 2002: Message edited by: Valentin Crettaz ]

SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cryptic java declaration