All Questions
Tagged with constructors parameters
6 questions
33
votes
3
answers
19k
views
Optional parameters or overloaded constructors
I am implementing a DelegateCommand, and when I was about to implement the constructor(s), I came up with the following two design choices:
1: Having multiple overloaded constructors
public ...
0
votes
1
answer
5k
views
Object constructors with dynamic parameter lists
I had a quick question and I was hoping someone could help me figure this out. I'm new to Java and I'm trying to learn about classes and objects and I see you can call parameters in the constructor of ...
10
votes
2
answers
847
views
Is it bad to create classes whose sole purpose is to be converted to another class implicitly?
Imagine a situation where we're using a library that allows you to create Circle objects, where you can specify the radius and the center of the circle to define it. However, for some reason, it also ...
8
votes
3
answers
6k
views
How to deal with constructors in large data classes [duplicate]
Several times now I have come across the situations where you have some kind of settings class that simply contains a mass of data. Often these classes are simply not valid without at least most of ...
0
votes
1
answer
692
views
Constructors, Ignore Arguments
Is it possible to have a constructor in a class, that you can ignore certain arguments/parameters?
For example, I have this constructor
Car(color, make, model, wheels, type, doors)
Could I call ...
6
votes
3
answers
4k
views
Is it better to have constructors with or without parameters?
Is it better to have constructors with or without parameters and why?
public NewClass( String a, String b, int c) throws IOException
{
//something
}
OR
public NewClass()
{
//something
}