U
User N
In cases where a variable can be initialized in the declaration or
constructor, which approach do you take? Are there any genuine
advantages to one approach over the other?
Example:
public class foo
{
private int maxItems = 5;
private ArrayList items = new ArrayList();
public foo()
{
}
}
vs
public class foo
{
private int maxItems;
private ArrayList items;
public foo()
{
maxItems = 5;
items = new ArrayList();
}
}
constructor, which approach do you take? Are there any genuine
advantages to one approach over the other?
Example:
public class foo
{
private int maxItems = 5;
private ArrayList items = new ArrayList();
public foo()
{
}
}
vs
public class foo
{
private int maxItems;
private ArrayList items;
public foo()
{
maxItems = 5;
items = new ArrayList();
}
}