Showing posts with label toString(). Show all posts
Showing posts with label toString(). Show all posts

Monday, 3 February 2014

Event Classes in java

The classes that represent events are at the core of Java’s event handling mechanism......

Event Classes

The classes that represent events are at the core of Java’s event handling mechanism. At the root of the Java event class hierarchy is EventObject, which is in java.util. EventObject contains two methods: getSource( ) and toString( ). 

The getSource( )method returns the source of the event. Its general form is shown here:

        Object getSource( )

As expected, toString( )returns the string equivalent of the event.The class AWTEvent, defined within the java.awt package, is a subclass of EventObject.It is the superclass (either directly or indirectly) of all AWT-based events used by the delegation event model. Its getID()method can be used to determine the type of the event. 

The signature of this method is shown here:

         int getID()

Sunday, 26 January 2014

PrintWriter class in java

how to use printwriter class..

The PrintWriter Class


Although using System.out to write to the console is acceptable, its use is recommended mostly for debugging purposes or for sample programs. Java is through a PrintWriter stream. PrintWriteris one of the character-based classes.Using a character-based class for console output makes it easier to internationalize your program. PrintWriter supports the print( ) and println( ) methods for all types including Object.