Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

This is for a beginning Java course that poses the problem:

Write a class named Employee that has the following fields:

  • name. The name field references a String object that holds the employee's name.
  • idnumber. The idnumber is an int variable that holds the employee's id number.
  • department. The department field references a String object that holds the name of the department where the employee works.
  • position. The position field references a String object that holds the employee's job title.

I am aware there is a similar question on these boards, but my problem does not include constructors, and the posted one does.

First, my public class java file:

public class employee {

private String name;
private int idnumber;
private String department;
private String position;

public void setName(String n){
    name = n;   
}
public void setID(int id){
    idnumber = id;  
}
public void setDepartment(String d){
    department = d;   
}
public void setPosition(String p){
    position = p; 
}

public String getName(){
    return name;
}   
public int getID(){
    return idnumber;
}

public String getDepartment(){
    return department;
}    
public String getPosition(){
   return position;
}
   }

Second, my main class code:

 public class EmployeeFile {

 public static void main (String[] args) 
 {
    employee One = new employee();
    employee Two = new employee();
    employee Three = new employee();

    One.setName("Susan Meyers");
    One.setID(47899);
    One.setDepartment("Accounting");
    One.setPosition("Vice President");

    Two.setName("Mark Jones");
    Two.setID(39119);
    Two.setDepartment("IT");
    Two.setPosition("Programmer");

    Three.setName("Joy Rogers");
    Three.setID(81774);
    Three.setDepartment("Manufacturing");
    Three.setPosition("Engineer");

   System.out.println("Name             ID Number            Department              Position");
   System.out.println("____________________________________________________________________");
   System.out.println(One.getName()+"\t"+One.getID()+"\t"+One.getDepartment()+"\t"+One.getPosition());

    }
}

This is the error I get:

run: Error: Could not find or load main class employee.EmployeeFile Java Result: 1

Any help, pointers or redirections to a previous solution I may have overlooked is much, much appreciated!

share|improve this question
1  
Code Review is for reviewing working code. If your code doesn't work, then your question is off topic here. – svick May 14 at 11:24

closed as off topic by abuzittin gillifirca, Brian Reichle, p.s.w.g, svick, Quentin Pradet May 14 at 11:48

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined by the community. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about reopening questions here.If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

I dunno, I just pasted your code into Eclipse (Android Developer Tools) and it worked fine for me:

javaProject.png

share|improve this answer
Thank you sir...I'm using Netbeans; wondering that's the problem? – Jordan Faris May 16 at 1:13
I appreciate the feedback on this, Mr. Thompson...I'll go back and try again. Take care, Jordan – Jordan Faris May 16 at 1:14

Not the answer you're looking for? Browse other questions tagged or ask your own question.