I have 4 classes, Main
, class A
, class B
, class C
.
I initiated a variable in Main, outside a loop_1 : int x=0
and then passed it into class A
that uses a loop_2, and then from there straight into class B
which is a part of that loop and right into class C
.
I intended that after class A
would finish the loop I'll get System.out.Println with X.
The problem is that I get x=0 every time. I have a checkUp System.out.println in class C
and I see it grow there, But as I try to print x from class class A
I always get x=0.
Note: I have
Main Class
public class SocketMain
{
public void mainMethod{
int x=0;
for (int edition = 0 ; edition<29 ; edition++){
classA.Method1(x);
x=0;
}
}
class A (SelfNote : // InstrumentPage)
public class classA
{
public static void Method1(int x)
{
for (int loopCounter = 0 ; loopCounter <29 ; loopCounter ++){
classB.Method2(x);
}
if (x=0)
System.outprintln("FirstIf" +x);
if (x>0)
System.out.println ("SecondIf" +x);
}
Class B (SelfNote : //TestClockOfInstrument)
public class classb
{
public static void Method2(int x)
{
classC.Method3(x);
}
Class C (SelfNote : //SocketChanges)
public class classc
{
public static void Method3 (int x)
{
if (someThingHappens == 1)
x++;
System.out.println ("Check X" +x);
}