Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extends object

Status
Not open for further replies.

yytan

Programmer
May 8, 2002
113
MY
hi there;

i think i got confuse again.

i dun get clear when java extends object, wat it does and which object it is inherit from since the class never specific wat is the class it will exteds.

pls help ;)

rgd/ yoke yew
 
Have you got a specific example you are having problems with ?

--------------------------------------------------
Free Database Connection Pooling Software
 
hi sedj;

example:

Code:
public class TraceWriter extends Object {
  /**
   * Members
   */
  short DBGLVL = 0;
  String PgmName = "DEFAULT";
  private DatagramSocket socket;

...
...

  public TraceWriter(String path) {
    setPropertyPath(path);
    try {
      socket = new DatagramSocket();
      address = InetAddress.getByName(HOST_NAME);
    } catch (SocketException e) {
      System.err.println("Error in opening Datagram socket: ");
      System.err.println(e.getMessage());
    } catch (UnknownHostException e) {
      System.err.println("Error in getByName(): ");
      System.err.println(e.getMessage());
    }
  }

i dun understand why this class TraceWriter need to extends object.

rgd/ yoke yew

 
The TraceWriter class has absolutely no need to extend Object at all, because ALL classes automatically *extend* the Object class (the compiler does this for you basically). This means that all objects have the methods available to them that are in the base Object class (such as toString() etc).

Its just bad programming to extend Object explicitly as it serves no purpose whatsover !

--------------------------------------------------
Free Database Connection Pooling Software
 
dear sedj;

10s for ur info. i am doing with diff prog lang all the time, tends to forget the fundamental 1.

rgd/ yoke yew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top