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

how to use getters and setters  RSS feed

 
Igbe Jr. Chukwudi
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,please am trying to initialize a variable in my setter method,but when i do so my getter method doesn't return the value.below is my code:

 
Mohamed Sanaulla
Bartender
Posts: 3174
34
Google App Engine Java Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont see anything wrong in the code you have provided. But how is it being used? Can you post a small working example? Also please UseCodeTags for putting the code.
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Like Mohamed said: please UseCodeTags, it will highlight your code making it much easier to read. This time I've added them for you.

The only thing I can see is that you're missing semicolons.
 
Frankely Diaz
Greenhorn
Posts: 20
Eclipse IDE Java jQuery
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Send the whole code in order to help you
 
Wouter Oet
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And it should be setAcct() and getAcct()
 
Rob Spoor
Sheriff
Posts: 21087
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Frankely Diaz wrote:Send the whole code in order to help you

Not the whole code. It should be limited to an SSCCE. We definitely don't want hundreds of lines of code where a handful would be enough to display the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!