1. PF Contest - Win "Conquering the Physics GRE" book! Click Here to Enter
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

JAVA: Object Oriented Programming Basics: Problem: class, interface, or enum expected

  1. Oct 10, 2009 #1
    public class Postman {
    private String Name;
    private int Age;

    How you can update and retrieve the private variables Name and Age from another class Worker.

    public class Worker {
    //An object a is created from class Postman

    What i tried to do:
    public class Postman{
    private String name;
    private int age;

    public Postman(String name, int age){

    public String getName(){
    return name;

    public int getAge(){
    return age;

    public class worker{
    public static void main(String args[]){
    Postman employee = new employee("Tom the postman", 55);


    But when i buid it, it keeps giving me the class, interface, or enum expected error. Why is that?
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted

Similar Threads - JAVA Object Oriented Date
Java: Calling On An Object Apr 5, 2015
Java - objects and methods Oct 27, 2012
Java object method Sep 19, 2011
Java adding two objects Sep 12, 2011
Java project output problem. Can't output objects from a method. Apr 13, 2008