java - How to put my variables in the object's constructor -


i have class has 20 attributes can devided in 10 groups having 2 attributes of type minvalue , maxvalue.

i wondering how define object's constructor. have 2 options:

first one,

public myclass(minvaluetype1, maxvaluetype1, minvaluetype2,maxvaluetype2,....,minvaluetype10, maxvaluetype10)  

second one,

public myclass(type1arr[],type2array[],......,type10array[]) 

where each array has length of 2 minvalue , maxvalue.

which way think better?

here 1 way

class myclass {   private map<string, minmax> others;   public myclass(map<string, minmax> in)   {     others=in;   } }  class minmax {   private int min;   private int max;    public boolean iswithinrange(int input)   {     return input >= min && input <= max;   } } 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -