Home Java Java-tips Summaries Summary: Classes, Interfaces

Ask Questions?

View Latest Questions

Advertisement


 
 

Summary: Classes, Interfaces
Posted on: July 27, 2006 at 12:00 AM
Defining the Classes and Interfaces.

Java: Summary: Classes, Interfaces

Packages

   package package-name;

Class Definition

A class definition prototype:
visibility class class-name [extends parent-class] [implements interface-name...] { class-body }
nameMeaning
visibility public -- visible to everyone.
private -- visible only in this class.
protected -- visible in this class and all subclasses.
The default visibility is package visibility -- everyone in the this package can see it.
parent-class This is the name of the parent class of this class. The default parent class is Object.
interface-name For each interface that is implemented, this class must define all methods in that interface.
class is used to define a record and its fields (members). Example: This defines a structure node, then declares x to be a node:
  class Node {
     int data;
     Node next;
     // methods
  }

import Statement

import
import java.awt.*;      // for a graphic drawing
import java.awt.event.* // for events and listeners
import javax.swing.*;   // for more GUI components
import javax.swing.event.*; // more listeners
Advertisement


DMCA.com