| Thread Closed |
JAVA: Object Oriented Programming Basics: Problem: class, interface, or enum expected |
Share Thread |
| Oct10-09, 02:22 AM | #1 |
|
|
JAVA: Object Oriented Programming Basics: Problem: class, interface, or enum expected
Question:
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: //Postman.java public class Postman{ private String name; private int age; } //constructor public Postman(String name, int age){ this.name=name; this.age=age; } //accessors public String getName(){ return name; } public int getAge(){ return age; } //worker.java public class worker{ public static void main(String args[]){ Postman employee = new employee("Tom the postman", 55); System.out.println(employee.getName(… System.out.println(employee.getAge()… } } But when i buid it, it keeps giving me the class, interface, or enum expected error. Why is that? |
| Thread Closed |
| Tags |
| java |
Similar discussions for: JAVA: Object Oriented Programming Basics: Problem: class, interface, or enum expected
|
||||
| Thread | Forum | Replies | ||
| The 'class name' in enum. | Programming & Comp Sci | 11 | ||
| object-oriented design’s sequence diagrams | Engineering, Comp Sci, & Technology Homework | 0 | ||
| Is object oriented programming unnecessary for scientific applications? | Programming & Comp Sci | 11 | ||
| Object-Oriented philosophy problem | Programming & Comp Sci | 2 | ||
| C++ not object oriented? | Computing & Technology | 2 | ||