I know that it isnt about my problem but just to you know, this is my first stackoverflow post and yes, my english isnt quite good so please, i sincerely ask you guys, be patience. I'd chosen english community because brazillian stack overflow community isnt this good as english version do.
About my problem, here it is:
public class Class5{
static int ia, ib;
public static Class5 InstanceClass5 = new Class5();
public Class5(){this(1, 2);}
public Class5(int ia){this(ia, 0);}
public Class5(int ia, int ib){this.ia = ia; this.ib = ib;}
// the only one important part of this class code
public static void returnConstructor(int ia, int ib){}
// ends here, the rest isnt important
public static int myVar = initializeClassVariable();
private static int initializeClassVariable(){int ia = 3; return ia;}
}
public class Main
{
static Scanner dataEntrance = new Scanner(System.in);
public Main(){}
public static Main Instancia1Main = new Main();
static int ia, ib;
// here my problem begins: i just did 2 static blocks initializers, but its working good.
public static int varType = InitializeClassVariable();
private static int InitializeClassVariable(){ia = Class5.ia; return ia;}
public static int varType2 = InitializeClassVariable2();
private static int InitializeClassVariable2(){ib = Class5.ib; return ib;}
public static void main(String[] args)
{
System.out.println(Class3.Instancia2Class3.Class3());
// It shows that the first static block initializer is doing what it was created to do: get the same value as "ia" class variable,
// inside Class5 (so, varType2 or InitializeClassVariable2 method is working by the same way, for sure)
System.out.println(Main.varType);
//final Main instancia1Main = Instancia1Main; -- it doenst have any importance for now
// AND FINALLY, THERES MY PROBLEM: inside Class5, returnConstructor method have 2 arguments: int ia, int ib
// To print this method values, i have to use 2 int arguments: why not varType and varType2
// or InitializeClassVariable and InitializeClassVariable2 (work by the same way... in theory)
// It supposed to work then...
System.out.println(Class5.InstanceClass5.returnConstructor(Main.InitializeClassVariable(), Main.varType2));
}
}
[Then it happens][1][1]: https://i.sstatic.net/cR8xH.png
I really got no idea why returnConstructor is receiving the listed arguments (Main.InitializeClassVariable(), Main.varType2) as void. System.out.println(Main.varType); -> It shows that varType isnt a void, and varType2 for sure do the same, someone have any idea about why its happening and how to fix that? I think thats all, thx everyone!
returnConstructor
doesn't return anything, so println
has nothing to print.