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 4 of 4

Thread: Help with object

  1. #1
    Junior Member
    Join Date
    Apr 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Help with object

    Hi This is my first post on this forum, so first I would like to say Hi!


    I have created a loop that returns a contact object by surName that is held in a contact list.

     
        public Contact print(String surName)
        {
     
             for(Contact contact : contacts)
             {
                 if(surName.equals(contact.surName))
                 {
                     contact.print();
                 }
            }
            //no match
            return null;
        }

    What I am trying to do now is return the details of the contact object and print them out as String or as Print method. Any ideas please?


  2. #2
    Member
    Join Date
    Apr 2010
    Location
    The Hague, Netherlands
    Posts
    91
    Thanks
    3
    Thanked 10 Times in 10 Posts

    Default Re: Help with object

    A few questions first:
    -What happens in the print() method of contact?
    -You want to print details from the class, but what is the problem? you dont know how to print? you dont know how to get the attributes?

  3. #3
    Junior Member
    Join Date
    Apr 2010
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Help with object

    in the print() method for contact...what coding do you write?

    if you want to print the detail in GUI there is some info from this 2 website below:

    How to Make Dialogs (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Swing Components)

    JOptionPane (Java 2 Platform SE v1.4.2)

    it about showing pop up message/output...

  4. #4
    Super Moderator Json's Avatar
    Join Date
    Jul 2009
    Location
    Warrington, United Kingdom
    Posts
    1,274
    My Mood
    Happy
    Thanks
    70
    Thanked 156 Times in 152 Posts

    Default Re: Help with object

    You might want to replace contact.print(); with return contact;

    // Json

Similar Threads

  1. write object to sql db
    By wolfgar in forum JDBC & Databases
    Replies: 3
    Last Post: May 18th, 2010, 10:03 AM
  2. object not accessible
    By sheikhms60 in forum Object Oriented Programming
    Replies: 1
    Last Post: February 22nd, 2010, 06:37 PM
  3. Class and Object
    By jyothishey in forum Object Oriented Programming
    Replies: 2
    Last Post: January 25th, 2010, 07:48 AM
  4. Object o = new Object(); need help
    By zeeshanmirza in forum Object Oriented Programming
    Replies: 11
    Last Post: January 6th, 2010, 09:01 PM
  5. Object Injection
    By Json in forum Java Programming Tutorials
    Replies: 1
    Last Post: December 4th, 2009, 03:08 AM