0
Java Classes
Example. I have 4 classes . 1 main 2 red 3 blue 4 black. How to in class 3 and 4 set Integer value with void method in class 2 and value import in class 1
2 Answers
0
Firstly, classes are written with capital letter, otherwise, I might mistake them with objects or variables. This can also be done without class instances, meaning using statc variables and methods.
publc class Black {
static int value=10;
}
public class Blue {
public static void setRedValue(){
Red.value = Black.value;
}
}
public class Red {
public static value int=0;
}
public Main {
public static void main (String [] args){
Blue.setRedValue();
System.out.println (Red.value)); // =10
}
}
0
How with setters and getters if value is private