Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 6 of 6

Thread: to get a help about compositions!!!!!

  1. #1
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default to get a help about compositions!!!!!

    these are 2 classes.
    can anyone explain me about the things in bold and the other contents.


    public class tuna{
    private String name;
    private potpie birthday;

    public tuna(String nm,potpie bday){
    birthday=bday;
    name=nm;
    }
    public String hs(){
    return String.format("My Name is %s, My Birthday is %s", name,birthday);
    }}

    public class potpie {
    private int year;
    private int day;
    private int month;


    public potpie(int y,int d,int m){
    year=y;
    day=d;
    month=m;
    System.out.printf("The date is %s\n", this);
    }
    public String toString(){
    return String.format(" %d/%d/%d",year,day,month);

    }}


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,602
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: to get a help about compositions!!!!!

    private potpie birthday;
    Defines a variable named birthday of type potpie.
    If you don't understand my answer, don't ignore it, ask a question.

  3. The Following User Says Thank You to Norm For This Useful Post:

    MHS (December 5th, 2012)

  4. #3
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: to get a help about compositions!!!!!

    What do you mean by the type potpie?

  5. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,602
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: to get a help about compositions!!!!!

    public class potpie {
    That defines a "type" named potpie.
    If you don't understand my answer, don't ignore it, ask a question.

  6. The Following User Says Thank You to Norm For This Useful Post:

    MHS (December 5th, 2012)

  7. #5
    Junior Member
    Join Date
    Dec 2012
    Posts
    6
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: to get a help about compositions!!!!!

    Can't you give another examples?

  8. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    SW Missouri
    Posts
    20,602
    Thanks
    50
    Thanked 2,235 Times in 2,207 Posts

    Default Re: to get a help about compositions!!!!!

    You'll get more and better answers if you google: java data types
    If you don't understand my answer, don't ignore it, ask a question.