Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

need some help on java classes!!!!!!!!!  RSS feed

 
Sally Curtis
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • 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.
 
Gabriel White
Ranch Hand
Posts: 233
  • Mark post as helpful
  • send pies
  • 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 ]
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • 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.
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!