Results 1 to 5 of 5
  1. #1
    Reero8532 is offline Member
    Join Date
    Mar 2010
    Posts
    9
    Rep Power
    0

    Default How can I get my array output result onto one dialog box???

    I'm having a huge problem trying to get my entire array output into a single Dialog Box instead of having one for every integer and string.


    Java Code:
    import java.util.*;
    import javax.swing.JOptionPane;
    
    
    public class Homework7 {
    
        public static void main(String []args)
        {
        String s;
    
        int numTests;
    
        s = JOptionPane.showInputDialog(null, "How many test grades have you given?");
        numTests = Integer.parseInt(s);
    
        JOptionPane.showMessageDialog(null, "The number of tests given is: " + numTests);
    
        int [] myGrades = new int [numTests];
    
        for (int i=0; i<=myGrades.length; i++)
            {
                String gradeIndex = "The grade at index " + i + " is " + myGrades[i];
                JOptionPane.showMessageDialog(null, gradeIndex);
            }
    
        } // end of main method
    I'm mainly trying to get my output below here:

    The grade at index 0 is 0
    The grade at index 1 is 0
    The grade at index 2 is 0
    The grade at index 3 is 0
    The grade at index 4 is 0
    etc......




    All onto 1 Dialog Box, instead of 1 box for each printed line.


    Also please elaborate on your suggestions as I am still very new to JAVA.

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Hello.

    Please read what JavaRanch says about cross-posting without being forthright about it: BeForthrightWhenCrossPostingToOtherSites

    The same etiquette applies here and in the other programming fora.

    I will list one cross-post: http://forums.sun.com/thread.jspa?th...55251#10955251
    Are there any others?

    Thanks in advance for your cooperation and best of luck.

  3. #3
    camickr is offline Senior Member
    Join Date
    Jul 2009
    Posts
    1,234
    Rep Power
    7

    Default

    Not only that, I gave you the answer yesterday when you asked the same question:

    How to display array integer in JOptionPane message dialog ?

  4. #4
    Reero8532 is offline Member
    Join Date
    Mar 2010
    Posts
    9
    Rep Power
    0

    Default

    No thats the only one, sorry for the inconvenience. I'm still very new to posting for help on forums.

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Well, for one, you may wish to reply to the reply to you in the other forum, and also while you're there, mention that you have cross-posted here. Obviously there's no need to mention that here since we've already done that. Luck.

Similar Threads

  1. Replies: 13
    Last Post: 03-20-2010, 01:03 AM
  2. Replies: 0
    Last Post: 03-10-2010, 02:13 AM
  3. Help with Array output Needed!
    By 2potatocakes in forum New To Java
    Replies: 2
    Last Post: 03-07-2009, 06:36 PM
  4. output from an array
    By @eddie.com in forum New To Java
    Replies: 5
    Last Post: 08-15-2008, 08:26 AM
  5. Simply output the result to a text file.
    By silvia in forum New To Java
    Replies: 1
    Last Post: 08-07-2007, 05:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •