• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

please help me out (about "composition")

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

what "composition "mean?
thank you!!
[ Jess added UBB [code] tags to preserve whitespace, check 'em out! ]
[ November 01, 2003: Message edited by: Jessica Sant ]
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok -- so I adjusted your code a bit (see my comments)

The WaterSource.toString() method is used to override Object.toString() method that every class inherits. This method is invoked whenever you try to print an objedct. So on the line I marked with **** the WaterSource.toString() method is invoked so that the contents of WaterSource is displayed however you choose.
When I run this code as you see it, I get the following output:
WaterSource()
value1 = some Value
source = pipes

Try commenting out the WaterSource.toString() method, so that the default toString() is used, and you get this (the exact value you get for source will vary from execution to execution:
WaterSource()
value1 = some Value
source = WaterSource@1a16869

Does that help?
[ November 01, 2003: Message edited by: Jessica Sant ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic