Changing variables of one class using method from another class

11 Views Asked by At

Ok so I have 2 classes for instance:

public class Boolean {
    public static void test(boolean test1, boolean test2, boolean test3, boolean test 4, boolean test 5, boolean test 6){
        test1 = true;
        test2 = true;
        test3 = true;
        test4 = true;
        test5 = true;
        test6 = true;
    }
}
    

public class Test {
    private boolean test1 = false;
    private boolean test2 = false;
    private boolean test3 = false;
    private boolean test4 = false;
    private boolean test5 = false;
    private boolean test6 = false;

    public static void main(String[] args) {
        Boolean.test(test1, test2, test3, test4, test6, test7);
        //I want test1,...,test6 to be true now.
    }

}

(This is just a simple example code to describe my problem, obviously this could be solved easier)

So I tried this apporoach for one of my projects however it does not seem to work. Any ideas why this wont work?

0

There are 0 best solutions below