I have a doubt regarding the initialization of variables of a class. When usually declare a class with the variables and I initialize (even if they are final) I do it via the constructor.
For example:
class Example {
private int a, b;
public Example () {
a = 5;
b = 10;
}
// Methods
}
But you can also initiate immediately after the statement.
For example:
class Example {
private int a = 5, b = 10;
// Methods
}
What is the best way to initialize variables? What is the difference?