You can use a method that returns a value any place in your program where you would use any other type of variable. code example
Example: how to create a function that returns in java
// a method for computing the area of the rectangle
public int getArea() {
return width * height;
}