Is there a difference in how these two methods work?

class InvoiceController{

private Map<String, String> addr = Collections.emptyMap();

// Empty Constructor

public InvoiceController (){}

}

versus

class InvoiceController{

private Map<String, String> addr;

public InvoiceController ( ){

addr = Collections.emptyMap();

}

}

Does it matter if it it initialized at the declaration or in the constructor?

I'm asking because I am using Spring and couldn't figure out how to initialize a Map in Spring with Collections.emptyMap() method.

[1021 byte] By [smiles78a] at [2007-11-26 19:50:19]
# 1
I don't think that it matters, but if you have more than one member to initialize, you have to be aware of the fact that initializations at the member declaration are executed before the constructor is called.
ProggerFromKupfera at 2007-7-9 22:39:39 > top of Java-index,Java Essentials,Java Programming...
# 2
Functionally they are the same. The first example would be preferrable though if you want to always initialize it to that value. So even if you later were to add another constructor, you wouldn't have to duplicate that line of code or invoke a common "initializer" method or constructor.
warnerjaa at 2007-7-9 22:39:39 > top of Java-index,Java Essentials,Java Programming...