Java Reference

Java Reference Home | Smart Soft Home

class

Category

Other

Description

A class is a code block consisting of instance variables and/or methods. Classes are the building blocks of java programs. Java programs consist of one or more classes. Typically, the class should be symbolic of some physical entity, such as a Room, a Customer or an Invoice. Java programming is the act of defining and using classes. We "use" a class by invoking its methods and accessing its properties. A class is a template for an object. A class is a data type, specifically, a reference data type.

Example

public class Room {



   int length;

   int width;



   int getArea(){

     return length*width;

   }



}