aspose file tools*
The moose likes Beginning Java and the fly likes Compile time errors with the program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Compile time errors with the program" Watch "Compile time errors with the program" New topic
Author

Compile time errors with the program

satya narayan reddy
Greenhorn

Joined: Nov 26, 2005
Posts: 13
hai iam new to this forum and new to java world too and hope u all will help me out in answering to my queries:

why the below program is giving the comiple time errors:
public class objectDemo
{
objectDemo()
{
System.out.println("iam in the construtor jectDemo()");
}
public Class getClass()
{
System.out.println("returns the class of the object");
}
public int hashCode()
{
System.out.println("returns the hashCode of the object");
}
public boolean equals(Object obj)
{
System.out.println("returns the boolean value of the object");
}
protected void copy(Object src)
{
System.out.println("copies the contents of specified into the current object");
}
public static void main(String args[])
{
objectDemo od = new objectDemo();
od.getClass();
od.hashCode();
od.equals(Object ramu);
od.copy(Object venkat);
}

}
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4753
    
    7

What does the compile time error message say? (I actually know what the error is. However, around here we like to help people learn how to help themselves)


Junilu - [How to Ask Questions] [How to Answer Questions]
satya narayan reddy
Greenhorn

Joined: Nov 26, 2005
Posts: 13
hi lancar
this is what the compiler is giving the errors.
so please tell me how to solve this errors

thanks,
reddy

objectDemo.java:28: ')' expected
od.equals(Object ramu);
^
objectDemo.java:29: ')' expected
od.copy(Object venkat);
^
Ko Wey
Ranch Hand

Joined: Sep 08, 2003
Posts: 67
od.equals(Object ramu);
should be
od.equals(ramu);

the compiler knows already that ramu is something of class Object, so if you remind him, he talks back...
satya narayan reddy
Greenhorn

Joined: Nov 26, 2005
Posts: 13
Hi Ko Wey,
Thanks for your suggestion but still iam getting comiple time errors as:

objectDemo.java:7: getClass() in objectDemo cannot override getClass() in java.l
ang.Object; overridden method is final
public Class getClass()
^
objectDemo.java:28: cannot resolve symbol
symbol : variable ramu
location: class objectDemo
od.equals(ramu);
^
objectDemo.java:29: cannot resolve symbol
symbol : variable venkat
location: class objectDemo
od.copy(venkat);
^


I can be thankful if anybody fixes these errors

Thanks,
VSNReddy
Ko Wey
Ranch Hand

Joined: Sep 08, 2003
Posts: 67
Mr. Reddy,

your main could look like this:


Every class you create is a subclass of Object. You inherit the methods of this class Object. Some of these you can "rewrite" (override), some you cannot because they are declared as final. getClass() is final, so you cannot override that method, as the compiler reminds you. So remove that method from your class, recompile and you can than read what the compiler thinks of your class' methods.... (hint: if you declare that your method will return an integer, you are obliged to do just that...)

May I suggest you pick up a good book on java, like (Headfirst java)
http://www.oreilly.com/catalog/hfjava2/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Compile time errors with the program