• Post Reply Bookmark Topic Watch Topic
  • New Topic

two classes to have a common string  RSS feed

 
youn kan low
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hallo

i have two classes and i want to pass the string depotName from the depot class to the vehicle homeDepot field
the classes are below



and vehicle



thanks for the help
 
fred rosenberger
lowercase baba
Bartender
Posts: 12564
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I changed your 'quote' tags to 'code' tags. it makes your source much more readable. next time, do what you did, but just use the 'code' button instead.
 
Paul Clapham
Sheriff
Posts: 22832
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But why would you want to do that? You're just going to have duplicate strings all over the place, with the possibility of some of them changing and leading to confusion. Wouldn't it make more sense for the Vehicle to have a reference to the actual Depot, rather than just a copy of the Depot's name?

Like this...

 
vipul bondugula
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, Paul is correct.

You can have a Depot reference in your Vehicle. so that duplicate properties are removed.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!