This program will help you understand the working of function and nested class in Java.
import java.util.*;
class SecondClass
{
    int demofunction(int n)
    {
           System.out.println("This will print the content inside the function");
           int m = 10;
           return m;
    }
}
class MainClass
{  
    public static void main(String args[])
    {
            int n = 20;
            SecondClass obj= new SecondClass();
            System.out.println("This will print the content of main class" + obj.demofunction(n));
    }
}