0

I'm creating a class called Location that has 7 instance variables, such as street, suburb, city, etc.

While I was creating all the different constructors with different signatures (including the default constructor), I started thinking that there must be an easier way to go about doing this. If I had a class with 15 or so instance variables, I could spend all day typing out the possibilities.

Am I right in thinking that there is an easier method?

metacubed
  • 7,031
  • 6
  • 36
  • 65
aidandeno
  • 307
  • 1
  • 2
  • 16
  • 2
    Check out [the Builder Pattern](http://www.javaworld.com/article/2074938/core-java/too-many-parameters-in-java-methods-part-3-builder-pattern.html). – Gabriel Negut Aug 20 '14 at 10:00

1 Answers1

3

You can use the builder pattern or chain the constructors.

Community
  • 1
  • 1
filip
  • 414
  • 3
  • 14