Results 1 to 3 of 3
  1. #1
    dokunbam is offline Member
    Join Date
    Oct 2013
    Posts
    2
    Rep Power
    0

    Default Pls me out on this arrays number printing

    I started learning programming just this week and i think am not doin bad
    pls help out on this array print out
    Java Code:
     public static void main(String[] args) {
            // TODO code application logic here
            int[][]aryNums;
            aryNums = new int [2][6];
            aryNums[0][0] = 10;  aryNums[1][0] = 60;
            aryNums[0][1] = 20;  aryNums[1][1] = 50;
            aryNums[0][2] = 30;  aryNums[1][2] = 40;
            aryNums[0][3] = 40;  aryNums[1][3] = 30;
            aryNums[0][4] = 50;  aryNums[1][4] = 20;
            aryNums[0][5] = 60;  aryNums[1][5] = 10;
     
            {
           System.out.println(aryNums[][] + " ");
            }
                   System.out.println(" ");
    Last edited by JosAH; 10-08-2013 at 02:34 PM. Reason: fixed the [code] ... [/code] tags and adjusted the title (the 'print' bug)

  2. #2
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,646
    Rep Power
    5

    Default Re: Pls me out on this arrays number printing

    You can print out arrays just by specifying the array declaration type.

    There are several ways to do do it. If you want them to print out in two columns, then just
    use a single loop and iterate thru the rows from 0 to 5. Print out the cols of 0 and 1 explicitly inside
    the print statement.

    Regards,
    Jim
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

  3. #3
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,798
    Rep Power
    7

Similar Threads

  1. Printing 2 2D arrays next to each other
    By Matthieu105 in forum New To Java
    Replies: 8
    Last Post: 02-14-2013, 04:29 PM
  2. Printing multiple arrays help...
    By Toffer_15 in forum New To Java
    Replies: 8
    Last Post: 01-24-2013, 09:35 PM
  3. Error while printing out arrays
    By cjgarcia in forum New To Java
    Replies: 1
    Last Post: 05-03-2012, 12:34 AM
  4. Printing the Number of Times a Number in a Range Shows up
    By space4rent00 in forum New To Java
    Replies: 1
    Last Post: 02-05-2010, 10:42 PM
  5. printing number of pos/neg numbers input?
    By shroomiin in forum New To Java
    Replies: 12
    Last Post: 09-25-2009, 02:15 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
  •