Mega Code Archive

 
Categories / Java Tutorial / Class Definition
 

Creating Objects of a Class

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();        } }