I\'m fairly new to programming, and I\'m confused about what it means exactly to return a value. At first, I thought it meant to output what value is being returned, but whe
In simple terms, it means to return the value to caller of the method...
So, in your example, the method getX would return the value of x to the caller, allowing them access to it.
class Class1{
static int x = 3;
public static int getX(){
return x;
}
public static void main(String args[]){
int myX = Class1.getX(); // return the value to the caller...
System.out.println(myX); // print the result to the console...
}
}