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

Thread: Need help with printing out info

  1. #1
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Need help with printing out info

    So basically Im trying to create a hospital program where someone can go in and do multiple functions including add a patient/doctor, edit their medical history, and then look at all of it. My problem is when I am trying to output a certain variable from an array of objects called patients. So basically have an array with each patient in an array cell and that patient includes multiple pieces of information, including name, age, id number, etc. My question is how can I just print one of those things off like I want patient in array cell 3's name. How can I do that?


  2. #2
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Need help with printing out info

    System.out.println( patientArray[3].getName() );

    Edit: Maybe it should be patientArray[2], but you get the idea.

  3. #3
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Need help with printing out info

    Thanks! Also is there some way you could do this in an arrayList? I switched over because its more dynamic and I cant get it to work now

  4. #4
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Need help with printing out info

    You should refer to the ArrayList API for these kind of answers. How does one get the item stored at a specific index in an ArrayList? You can find out how to do that in the API. That's how you'll learn to fish (instead of being handed the fish), and gain confidence in using the API.

  5. The Following User Says Thank You to GregBrannon For This Useful Post:

    Diesel298 (October 4th, 2013)

  6. #5
    Junior Member
    Join Date
    Nov 2012
    Posts
    10
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Need help with printing out info

    Thank you very much!

Similar Threads

  1. How to get info from ListFragment
    By mellomel70 in forum Android Development
    Replies: 0
    Last Post: November 16th, 2012, 04:50 PM
  2. Date info
    By deependeroracle in forum Java Theory & Questions
    Replies: 1
    Last Post: March 14th, 2012, 05:36 PM
  3. Replies: 1
    Last Post: September 28th, 2011, 07:29 AM
  4. [SOLVED] Printing Array without printing empty elements
    By CarlMartin10 in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 12th, 2010, 02:41 AM