Results 1 to 2 of 2
Thread: I am not able to print Address
- 07-09-2007, 08:12 PM #1
Senior Member
- Join Date
- Jun 2007
- Posts
- 114
- Rep Power
- 0
I am not able to print Address
I need help with this program. I am not able to print Address through the main method
Java Code:public class Employee { private String id; private String Address; public Employee(String id,String fname,String lname,String city,String state,String zip) { this.id = id; Address address = new Address(fname,lname,city,state,zip); System.out.printf(" %s\n%s\n ",id,address.toString()); } public String toString() { return String.format("%s\n %s:\n ",id,Address); } public static void main (String args[]) { Employee e= new Employee("1000","Vijaya","Nimma","Detroit","MI","48334"); System.out.printf(e.toString()); }
Albert:rolleyes:
- 07-13-2007, 04:37 PM #2
Member
- Join Date
- Jul 2007
- Posts
- 44
- Rep Power
- 0
First of all, where is the Address class. The following line indicates that you have a class of type Address.
Java Code:Address address = new Address(fname,lname,city,state,zip);
Java Code:private String Address;
Solution: You must either declare a class of type Address that would handle the processing of Employee's addresses and, you must make sure that you stick to Sun Java Conventions so that other developers can read your code.
For example, a variable should not start with a capital letter etc.
Similar Threads
-
JSP getting IP address
By Java Tip in forum Java TipReplies: 0Last Post: 01-29-2008, 10:05 AM -
Print XML tag
By DonCash in forum XMLReplies: 2Last Post: 08-07-2007, 07:02 PM -
doubt about PRINT API
By valery in forum New To JavaReplies: 1Last Post: 08-06-2007, 10:51 PM -
Print A Pdf
By Jack in forum Advanced JavaReplies: 2Last Post: 07-02-2007, 06:40 AM -
print .doc in java
By Alan in forum Advanced JavaReplies: 1Last Post: 05-17-2007, 05:05 AM
Bookmarks