• Post Reply Bookmark Topic Watch Topic
  • New Topic

Another frustrated noob needs some help with methods in classes..  RSS feed

 
Daniel Ungerfält
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator





Why do I get the result brand null, colour null?
I know what null means but what am I missing here?
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Your setInf() method has the variable assignment wrong. Should be:
brand=b
color=c

The variable you want to assign to is on the left.

Also using public variables are not good practice. It is better making variables private and use getters to retrieve.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!