I'm so lost

I am a student in a Java programming class. I'm reading my textbook and several online postings, but I am missing something and I feel like it must be something very obvious.

I need first of all to write a class that goes with a program, but I need to be able to compile each class, before it will work with the main program, right?

This is just to get a name. Can anyone help? Thanks!

This is my code and the errors are commented:

//This is an employee class from which you get the employee name.

public class EmployeeName.java

{

//main method begins program execution

public static void main( String args[] )

{

public void setEmployeeName (String EmployeeName)

//ERROR: EmployeeName.java:3: '}' expected

//public class Employee.Name.java (with a ^ under the . between

// Name and Java)

{

EmployeeName = new EmployeeName();

} //end setEmployeeName

//returns the name string

public String getEmployeeName();

//ERROR: EmployeeName.java:9: illegal start of expression

// public void setEmployeeName (String EmployeeName)

//with the ^ under the P in public

{

return EmployeeName;

}//end getEmployeeName

} //end main

} //endclass EmployeeName

//ERROR: EmployeeName.java:22: class, interface, or enum expected

} //endclass EmployeeName -> [arrow] (with the ^ under the })

[1452 byte] By [newbie8a] at [2007-11-26 18:49:56]
# 1

Try this to get you up and running.

public class EmployeeName

{

private String name;

public static void main(String args[])

{

EmployeeName eName = new EmployeeName();

eName.setEmployeeName("Mike");

System.out.println(eName.getEmployeeName());

}

public void setEmployeeName (String name)

{

this.name=name;

}

public String getEmployeeName()

{

return name;

}

}

kikemellya at 2007-7-9 6:23:58 > top of Java-index,Java Essentials,New To Java...
# 2

There are so many mistakes in your code, I can't think of a place to start.

My advice is to get some one-on-one help. Meet with your instructor/prof/TA

or pay to have some tutoring.

Here is what you may have been trying to write, for comparison:

public class EmployeeName {

private String name;

public void setEmployeeName (String employeeName) {

name = employeeName;

}

public String getEmployeeName() {

return name;

}

public static void main(String[] args){

EmployeeName sampleName = new EmployeeName();

sampleName.setEmployeeName("Simpson, Homer");

String output = sampleName.getEmployeeName();

System.out.println(output);

}

}

DrLaszloJamfa at 2007-7-9 6:23:58 > top of Java-index,Java Essentials,New To Java...
# 3
Also, your class should probably be called Employee, not employeeName. have a play around with the code. add variables like "sex","salary" and "department". create methods for getting and setting (getters & setters) like with name and then use System.out to print them.
kikemellya at 2007-7-9 6:23:58 > top of Java-index,Java Essentials,New To Java...
# 4
Thank you. I think I see the differences.Believe it or not, I copied a lot of the code from my textbook and I get really confused when that doesn't work.
newbie8a at 2007-7-9 6:23:58 > top of Java-index,Java Essentials,New To Java...
# 5
Thanks again
newbie8a at 2007-7-9 6:23:58 > top of Java-index,Java Essentials,New To Java...