If you want a shorter expression for creating an array of wheels, then you have a simple one, since it can be obtained without additional methods.
You can create a factory method, for example:
class Wheel {
public static Wheel[] newWheels( int[] sizes ){
Wheel[] result = new Wheel[sizes.length];
for( int i=0; i < sizes.length; i++ )
result[i] = new Wheel( sizes[i] );
return result;
}
}
What would your expression about making a wheel do:
Wheel[] wa = Wheel.newWheels( new int[]{ 15, 17 } );
It is not much simpler if you have only two wheels of a given size, but if you have more of them or if you have not set sizes, it can be more readable.
source
share