+ 3

Is there a faster way to assign the variables in a class constructor?

I'm trying to assign a metric ton of values passed to a class constructor to variables declared in the class. Is there a faster way to do this? class Example { int a,b,c,d,etc; example(int inA, int inB, int inC, int inD, int inEtc) { a=inA; b=inB; c=inC; d=inD; etc=inEtc; } /* Any optimizations/shortcuts are welcome, even in the parameter declaration! */

2nd Oct 2018, 6:18 PM
Marvin Lee
Marvin Lee - avatar
4 Réponses
+ 1
Ina Well, they're all necessary and individual so sadly I can't. Thanks for the help though.
2nd Oct 2018, 7:14 PM
Marvin Lee
Marvin Lee - avatar
+ 1
Of course you can! thats why you use modern IDE! such as eclipse they have constructor generator! :D
3rd Oct 2018, 1:27 AM
Owenizedd
Owenizedd - avatar