Welcome to the Ranch
Please look at our link about
the code button; it isn't obvious at first how to use it, but you put the code between the [code=java] part and the [/code] part. Since you are new I have corrected it.
If you hit problems, please ask for help early; it is much easier to help if you have written only a little code. The small parts I have read look good, but why are you matching a field
description with a constructor parameter
name?
Actually passing parameters to constructors is the same whether they are reference types or primitives. Let's have a Kettle which contains
water when new, so its constructor might look like this:-
. . . and you can call it like this, assuming the Water object already exists:-
Beware: Strings are immutable and
ints are primitives, so there is no need for a defensive copy of them, but Water might be mutable, so take a defensive copy OR tease the object apart into primitives and immutable objects, to maintain the integrity of your object. Your property class doesn't (I think) need any defensive copying.
Two old posts about defensive copies:
1 2.