0

helow everyone!when i execute the following code,i have saved it as validateInfo.java it tells me that line 5:duplicate class:validateInfo.Please help

public interface validateInfo 
{ 
    public void validate(String empcode, String password); 
} 
class validateInfo implements validateInfo 
{ 
    public void update() 
    { 
        //code to update information of customer 
    } 
    public static void main(String a1[]) 
    { 
updateInfo o= new updateInfo(); 
p.update(); 
        System.out.println("Information updated"); 
    } 
}

Edited by Reverend Jim: Fixed formatting

3
Contributors
2
Replies
3
Views
6 Years
Discussion Span
Last Post by javaAddict
0

You have a class and an interface with the same name, and that's not allowed.
ps: Java convention is that interface and class names should begin with a capital letter.

0

Use code tags. And the error says: line 5. How are we suppose to know which is line 5 the way you posted. Try next time to show where that line is.
Press the button (code) when you create a post and put your code inside.

Also the problem is: class validateInfo implements validateInfo
The class names must be unique. You cannot have 2 classes with the same name. And when I say classes, I mean java files. You must use different file names and class names for each file. Change the validateInfo file's name to something else. And do the same inside the code. For example:

validateInfo.java
ValidateInfoImpl.java

You should try this:

class ValidateInfoImpl implements validateInfo {
....
}

Also in your main you do this:

updateInfo o= new updateInfo()

And I don't see where you have the updateInfo class defined. I think you should do this:

class ValidateInfoImpl implements validateInfo
{

 public void update()
 {
   //code to update information of customer
 }

 public static void main(String a1[])
 {
    ValidateInfoImpl o = new ValidateInfoImpl();
    o.update();
    System.out.println("Information updated");
 }
} 

And another tip. It is common to have the files start with capital letter.

Edited by mike_2000_17: Fixed formatting

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.