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.


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

Results 1 to 2 of 2

Thread: question about printing arrays

  1. #1
    Join Date
    Aug 2013
    Thanked 0 Times in 0 Posts

    Cool question about printing arrays

    For my java assignment this time, I want to know how to print an array value in a string. Here's the problem:


    After the following code is executed, what are the values of p[ 3 ], q[ 3 ], and r[ 3 ]? Explain. (As you work toward formulating your answer, you might want to add a System.out.println method to the program in the box provided.)

        String[] p = { "A", "B", "C", "D", "E" }; 
        String[] q = { p[ 0 ], p[ 1 ], p[ 2 ], p[ 3 ], p[ 4 ] }; 
        String[] r = p; 
        p[ 3 ] = "Z";

    That's the code they give me. What do I add to that to print the right thing? All responses appreciated.

    Sincerely, ghostheadx

  2. #2
    Super Moderator jps's Avatar
    Join Date
    Jul 2012
    My Mood
    Thanked 263 Times in 232 Posts

    Default Re: question about printing arrays

    The point of this assignment is to get you to understand the indexing system used for arrays. This tutorial explains the topic well.

    On to your question, search System.out.println to see how it is used.
    What were you told to print? ...read the instructions again.
    Note that printing is not required, it is like a verification system to show the actual answer so you can compare to your answer; like when you use subtraction to verify addition.

Similar Threads

  1. [SOLVED] Printing arrays
    By polop050505 in forum What's Wrong With My Code?
    Replies: 17
    Last Post: April 26th, 2013, 05:54 PM
  2. printing distinct numbers with arrays
    By ColeTrain in forum What's Wrong With My Code?
    Replies: 2
    Last Post: November 16th, 2012, 09:32 AM
  3. Counting a total and printing value from 2 arrays
    By stewart86 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 2nd, 2012, 07:25 AM
  4. Replies: 1
    Last Post: September 28th, 2011, 07:29 AM
  5. Printing a Histogram Help - Arrays
    By Mock26 in forum Collections and Generics
    Replies: 1
    Last Post: June 4th, 2009, 04:49 AM

Tags for this Thread