Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
  • 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

need some help on java classes!!!!!!!!!

 
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi i was just wondering what the accessors of a class were suposed to do and constructors too? i am a bit confused about the two.
 
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A constuctor and and accessor are both methods that are called by other classes, or within that class. The constructor must be named the same as the class that it is in. The accessor method is usually a method that returns something.
For example

HTH
Steve
[ January 20, 2004: Message edited by: Steve Wysocki ]
 
(instanceof Sidekick)
Posts: 8791
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Constructors have some special magic in the language. For one thing, they are called when you do new - using Steve's example maybe
Test myInstance = new Test( someInt );
You'll also hear about "default constructor" which simply has no arguments.
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Sally,
If you were "just wondering," why does your subject line include eight exclamation points?
I don't mean to pick on you, but please remember that everyone thinks their questions are important. Subject lines with "URGET" or "!!!" in them don't lead to their messages being answered more quickly -- in fact, often the opposite is true, because such subject lines annoy many people who then will steer clear of the message.
A subject line like "What are constuctors and accessors?" would have been much more appropriate.
 
A lot of people cry when they cut onions. The trick is not to form an emotional bond. This tiny ad told me:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic