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

by kloong
Tags: java
kloong is offline
Oct10-09, 02:22 AM
P: 35
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?
Phys.Org News Partner Science news on
SensaBubble: It's a bubble, but not as we know it (w/ video)
The hemihelix: Scientists discover a new shape using rubber bands (w/ video)
Microbes provide insights into evolution of human language

Register to reply

Related Discussions
The 'class name' in enum. Programming & Computer Science 11
object-oriented design’s sequence diagrams Engineering, Comp Sci, & Technology Homework 0
Is object oriented programming unnecessary for scientific applications? Programming & Computer Science 11
Object-Oriented philosophy problem Programming & Computer Science 2
C++ not object oriented? Computing & Technology 2