I want to know what it's the correct way to do that things in Java. My test code:
public class InitializeTest {
int i;
int b;
int x;
String frase;
public static void main (String args[]) {
InitializeTest IT = new InitializeTest();
System.out.println(IT.i=IT.getI());
System.out.println(IT.b=IT.getB());
System.out.println(IT.x=IT.getX());
}
public int getI(){
return 3;}
public int getB(){
return 5;}
public int getX(){
return 8;}
}
Should i initialize the variables i, b and x or not? What changes if not? I read about this but it's not clear for me, can anyone give me a clear answer?
I read about that here Do I really have to give an initial value to all my variables? , but don't know if is the same for Java.