public class Employee{
   public String fNa;
   public String lNa;
   public String Title;
   public int    ID;
  void doEmpThings()
}

 public class Director extends Employee{
     void doDrictorThings()

}

public class UseEmployee{
 public static void main(String []args)
  {codes}
}
  public class UseDir{
  public static void main(String []args)
  {codes }
}

Now what i now discover is that each time i try to run the UseDir, the result given is always that of Employee codes, i don't know what to do, do i need to have common main method for them or the do i need to have the separably, well both are in the same package employeeand the editor i use is NetBeans how do i go about it.

Recommended Answers

All 6 Replies

Are all those classes in separate Java files? How are you running the UseDir class?

yes, in different files but in the same package, then for my UseDir it's a class on it own from where i run Dir class apart from useEmpl class but which keep giving UseEmpl result
Thanks so much ~s.o.s~,look forward to more suggestion(s)

I don't have a Netbeans installation handy with me but can you try to rebuild the entire project (after cleaning the project) and then right click on the UseDir class and then select run? Also, are you sure that you have different code inside the main() method of both the classes?

so ... what code is there in your methods? would be able to give us a hint of what your code is doing.
just saying:

public class UseEmployee{
public static void main(String []args)
{codes}
}
public class UseDir{
public static void main(String []args)
{codes }
}

doesn't really say much. what is "codes"? and, are UseEmployee and UseDir also in seperate files? looking at the indentation, I would think they are in the same file, which could explain the problem you're having as well.

I don't have a Netbeans installation handy with me but can you try to rebuild the entire project (after cleaning the project) and then right click on the UseDir class and then select run? Also, are you sure that you have different code inside the main() method of both the classes?

~s.o.s~
i thank you so well for all the professional advice, tutor, and guide, i did it the way you ask me to, and every class is now working the way they ought to, all the main methods for the class are now coming out with their respective variables and methods
Thanks once again

gyno

so ... what code is there in your methods? would be able to give us a hint of what your code is doing.
just saying:

public class UseEmployee{
public static void main(String []args)
{codes}
}
public class UseDir{
public static void main(String []args)
{codes }
}

doesn't really say much. what is "codes"? and, are UseEmployee and UseDir also in seperate files? looking at the indentation, I would think they are in the same file, which could explain the problem you're having as well.

Tow of them .are in the same package, then for the Employee class, i created UseEmployee main method to lunch, in where the "members" of it class reside and for the Manager class, i created UseManager main method to lunch it as well. While the "codes" you mention, its just to indicate the individual codes that follows, in each class, since they still have few different "members" that further define each of the class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.