Begineer in coding please help me

Begineer in coding please help me

I have Person class{

int pid; String Pname;

//and have a Address filed of type Address not String!!!

Address add;

}

i know i should create a

class Address{

String state; Sting country; int pincode;

}

how to use this Address data type in my Person class to set address to a person object.. please help me

View Answers

June 4, 2013 at 5:05 PM

hi friend,

Try the following code may this will be helpful for you.

Address.java

package net.roseindia.simpleExample;

public class Address {

    String state;
    String country;
    int pincode;
    public String getState() {
        return state;
    }
    public void setState(String state) {
        this.state = state;
    }
    public String getCountry() {
        return country;
    }
    public void setCountry(String country) {
        this.country = country;
    }
    public int getPincode() {
        return pincode;
    }
    public void setPincode(int pincode) {
        this.pincode = pincode;
    }   
}

Person.java

package net.roseindia.simpleExample;

public class Person {

    int pid;
    String pName;
    Address add;

    public int getPid() {
        return pid;
    }
    public void setPid(int pid) {
        this.pid = pid;
    }
    public String getpName() {
        return pName;
    }
    public void setpName(String pName) {
        this.pName = pName;
    }
    public Address getAdd() {
        return add;
    }
    public void setAdd(Address add) {
        this.add = add;
    }   
}

Main.java

package net.roseindia.simpleExample;

public class Main {

    public static void main(String args[])
    {
        Address address = new Address();
        address.setCountry("India");
        address.setPincode(110085);
        address.setState("Delhi");

        Person person = new Person();
        person.setPid(1);
        person.setpName("Deepak");
        person.setAdd(address);     

        int pid = person.getPid();
        String name = person.getpName();
        Address add = person.getAdd();
        String country = add.getCountry();
        int pincode = add.getPincode();
        String state = add.getState();


        System.out.println(pid+" "+name+" "+state+" "+country+" "+pincode);
    }
}

Thanks.









Related Tutorials/Questions & Answers:
Begineer in coding please help me
Begineer in coding please help me  I have Person class{ int pid; String Pname; //and have a Address filed of type Address not String!!! Address... address to a person object.. please help me
problem in writing coding. Please help me.
problem in writing coding. Please help me.  Hi sir, my name is Logeswaran. I have problem in writing JSP coding for my university assigments... like? I'm really stuck on this. Please help me. By the way, I'm using Access
Advertisements
please help me in coding this given program
please help me in coding this given program  consider the below series: 1,2,1,3,2,5,3,7,5,11,8,13,13,17,..... this series is a mixture of 2 series... in this series. (i m unable to code this program..please provide solution
please help me in coding this given program
please help me in coding this given program  consider the below series: 1,2,1,3,2,5,3,7,5,11,8,13,13,17,..... this series is a mixture of 2 series... in this series. (i m unable to code this program..please provide solution
Please give me coding for this..
Please give me coding for this..  Write an application that inputs one number consisting of five digits from the user.separates the number ibto its individual digits and prints the digits separated from one another by three
Begineer Help Help Please Thanks A million ) I am using Jcreator
Begineer Help Help Please Thanks A million ) I am using Jcreator  System.out.println(" Income Statement...(Arrays.toString(Year)); The problem of this coding is that it will show null values before
please help me
please help me  Dear sir, I have a problem. How to write JSP coding, if a user select a value from drop down list for example department, the another... before. This name list should get from the database. Please help me. By the way, I'm
please help me.
please help me.  Please send me a code of template in opencms and its procedure.so i can implement the code. Thanks trinath
please help me.
please help me.  How to read a properties file in java with a suitable example. Please send me. Thanks Trinath   Please visit the following link: Java read properties file
urgent...pleAse help me.....please!
urgent...pleAse help me.....please!  please help me urgent! how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please help me.
please help me.  Please send me the validation of this below link. the link is http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html Thanks Trinath
please help me.
please help me.  How to move the edits.jsp in below link? http://www.roseindia.net/answers/viewqa/JSP-Servlet/9584-JSP-Servlet-Search-and-Edit.html
please help me.
please help me.  I have a jsp page under that i add a list box under i get the countries through my database. so how can i do
help me please
help me please   Hello I want helping for this question , Please Write a program that reads some friendsââ?¬â?¢ names, stores them in an array, and then prints out on the screen all friends who start by a particular letter
please help me.
please help me.  I have three table in mysql,and i hava create a excel sheet and add this sheet.but my question is in every sheet i can display one one table result.how can i do
Please help me.
Please help me.  Hi i am trinath in below there is a url.In that url there is a code of edit a jsp page.I understand that code but only one thing i not get it i.e; What is the work of "id".and what is the data type of id? http
please help me...
please help me...  write an application that print number in the following order using a FOR-Loop 1 2 3 4 5 2 4 6 8 10 3 6 9 1215 4 8 121620 5 10152025
please help me in these prog
please help me in these prog   create 2 jdbc programs including awt create 2 jdbc programs including swing create 2 jdbc programs including command line argument create 2 jdbc programs including io class 4 jdbc prog using
please help me to this problem..
please help me to this problem..  i wrote a program like keyboard... inside the JTextField) but i want to make this program to let me write where i clicked (i.e allows me to write any thing at the field where i clicked
Please help me urgent...........
Please help me urgent...........  For what kind of a problem would use a Tree Set and not a Tree Map For what kind of a problem would use a Tree Map and not a Tree Set   Hello Friend,ADS_TO_REPLACE_1 If you want
Please help me
Please help me  program for when a user enter his card number, it has to create default security pin in the database
Please help me
Please help me  Hi Sir, please send me the code for the following progrems... 1) all sets are integer type: input: set1={10,20,30,40} set2={15,25,35} output: union={10,15,20,25,30,35,40} 2) input: "Hi what
please help me
please help me  interface Test1 { String toString(); } public class Test { public static void main(String[] args) { System.out.println(new Test1() { public String toString() { return "test
please help me?
please help me?  Define a class named Circle with the following properties: List item An integer data field named radius with protected access modifier, and a String data field named colour with private access modifier. Both
Please help me??
Please help me??  Question_1: Using one-dimension array of primitive type elements. Objective: The purpose of this lab exercise is to practice how to declare, create and manipulate a one-dimension array of primitive type
Please help me out
Please help me out    Description* You are hired to develop a laptop inventory information system for Sheridan College in order to keep track of the information about the laptops lent to the students. Users can add or remove data
help me please
help me please  how can i do dictionary with the use of array code in java, where i will type the word then the corresponding meaning for that word will appear...thanks
please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels
please help me
please help me  how to use two browse buttons, one browse button for displaying the first image and second for the second image along with its file path and also to display text file along with its path using layouts or panels
please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D
please help me here
please help me here  please show me how can this show the right output that i need please continue doing this program using only if else and do while please please" here is the problem Automatic Teller Machine [B] Balance [D
Please help me to learn - WebSevices
Please help me to learn  Please help me to learn Java Fast
Please help me to create this coding for pizza order application using a handheld computer.....
Please help me to create this coding for pizza order application using... in the kitchen which displays the orders to be cooked. anybody please help me... ? Lemonade RM3.80 ? Fizzy orange RM4.90 The system must contain the HELP
please help me to overcome this problem
please help me to overcome this problem  how to make it easy to write java code. can u please give me suggestions
HQL Statement: Please help me
= Product.productGroupVersionId and Product.lobId = ? Can you please help me equallent HQL...HQL Statement: Please help me  Select ProductFamily.* from ProductFamily, ProductGroup, Product where ProductFamily.productFamilyVersionId
Please help me understand this query
Please help me understand this query  Hi, Could someone please help me understand the following query. Im finding difficulty relating it :-( Pls Help! select * from cbpartner where CBPartner.IsSummary='N' and salesrep_id
Help me please!!! - Java Beginners
Help me please!!!  im badly needing the complete code for this project in java!!! can you please help me???!!! it is about 1-dimensional array... the answers 8Hours from now!!! Kindly help me!! please!!please!!! NOTE
would you please help me?
would you please help me?  Write a class Amount which stores sums of money given in pounds and pence. Your con- structor should take two ints, for pounds and pence seperately. The class should also provide methods to add
please help me - Java Beginners
please help me   I have some error in this programe //write acomputer programe using java to generate following series : //output: //1,2,3,0,-2,7,-4..... class Series1HW { public static void main(String args
Coding errors for printing function, please help
. Can someone please take a look and help me to fix this. Although...Coding errors for printing function, please help  Hello, We, my...; Please visit the following link: http://www.roseindia.net/java/example/java
Please help me... its very urgent
Please help me... its very urgent  Please send me a java code to check whether INNODB is installed in mysql... If it is there, then we need to calculate the number of disks used by mysql
Help me please with my final homework
Help me please with my final homework  Write a Java program of your choice that demonstrates the following concepts: ? Input and Output. ? Selection/Conditional (e.g. if statement). ? Arithmetic. ? Loops. ? Arrays
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 2 1 1 3 4 3 1 1 4 7 7 4 1
please help me to write a code for this program
please help me to write a code for this program   1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
please help me to give code - Java Beginners
please help me to give code  Write a function with a signature cheerlead(word) that prints a typical cheer as follows. The word robot: Gimme an R Gimme an O Gimme a B Gimme an O Gimme a T What did you give me? ROBOT
please help me to give code - Java Beginners
please help me to give code  Write a function, sliding(word, num)that behaves as follows. It should print out each slice of the original word having length num, aligned vertically as shown below. A call to sliding(examples, 4
Please help me about maven2 plugin - Maven
Please help me about maven2 plugin  First, thanks you for your all... an error. I send you the image i capture the error Please help me... maven plugin. When i go to help/software update/ find and install/ search
hi.. please give me a java coding for the following question
hi.. please give me a java coding for the following question  Write a program that prompts the user to enter the number of students and each studentâ??s name and score, and finally displays the name of the students
please help me to give code - Java Beginners
please help me to give code  Write a program that prints an n-level stair case made of text. The user should choose the text character and the number of stairs in the stair case * ** *** ****   Hi friend
please help me to give code - Java Beginners
please help me to give code  Write a program that uses loops to generate an n x n times table. The program should get n from the user. As a model here is a 4 x4 version: | 1 2 3 4

Ads