class Sphere { double radius; // Radius of a sphere Sphere() { } // Class constructor Sphere(double theRadius) { radius = theRadius; // Set the radius } } public class MainClass { public static void main(String[] arg){ Sphere sp = new Sphere(); aMethod(sp); } private static void aMethod(Sphere sp){ System.out.println(sp); } }
5.3.Defining Method | ||||
5.3.1. | Methods | |||
5.3.2. | Passing Objects to a Method | |||
5.3.3. | Returning From a Method |