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

Thread: Pls me out on this arrays number print

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Pls me out on this arrays number print

    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(" ");


  2. #2
    Member
    Join Date
    Mar 2011
    Posts
    198
    My Mood
    Daring
    Thanks
    7
    Thanked 4 Times in 4 Posts

    Default Re: Pls me out on this arrays number print

    what is the problem with it exactly.. explain more what the problem is and what you are trying to achive..

    --- Update ---

    Quote Originally Posted by dokunbam View Post
    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(" ");
    also System.out.println(aryNums[][] + " ");
    sounds like its completely wrong I have not tried it or tried this method if it would even work but I would perhaps do a for loop like this
    for(int x = 0; x < 6; x++)
    {
     
    System.out.println(arryNums[0][x] + " ");
    System.out.println(arryNums[1][x] + " ");
    }
    Apart from that please tell us your problem...

  3. The Following User Says Thank You to macko For This Useful Post:

    dokunbam (October 8th, 2013)

  4. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Pls me out on this arrays number print

    i want to create rows and column with those numbers and run it

  5. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: Pls me out on this arrays number print

    You post is still vague and is not a specific question. Please do not respond with "how do I create rows and column with those numbers an run it?"

    You need o fully explain what you are trying to achieve. Perhaps include a sample output.

    --- Update ---

    Pls me out on this arrays number printing

    Duplicate post
    Improving the world one idiot at a time!

  6. #5
    Junior Member
    Join Date
    Oct 2013
    Posts
    14
    Thanks
    4
    Thanked 0 Times in 0 Posts

    Default Re: Pls me out on this arrays number print

    what am trying to do is to create array spreadsheet where the numbers will display in rows and columns
    not on a single line

    public static void main(String[] args) {
    // TODO code application logic here
    int[][]aryNums;
    aryNums = new int [3][6];
    aryNums[0][0] = 10; aryNums[1][0] = 60; aryNums[2][0] = 60;
    aryNums[0][1] = 20; aryNums[1][1] = 50; aryNums[2][1] = 60;
    aryNums[0][2] = 30; aryNums[1][2] = 40; aryNums[2][2] = 60;
    aryNums[0][3] = 40; aryNums[1][3] = 30; aryNums[2][3] = 60;
    aryNums[0][4] = 50; aryNums[1][4] = 20; aryNums[2][4] = 60;
    aryNums[0][5] = 60; aryNums[1][5] = 10; aryNums[2][5] = 60;
     
    // 
    int row = 6;
    int column = 3;
    int x, y;
    for (x = 0; x < row ; x++){
    for (y = 0; y < column ; y++){ 
    }
     
    System.out.println(aryNums[x][y] + " ");
    }
    System.out.println("");
    }

  7. #6
    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: Pls me out on this arrays number print

    For starters, change the first 'println()' to 'print()'. That will remove the linefeed from between each number in a row.

    Good luck!

  8. #7
    Member
    Join Date
    Aug 2013
    Posts
    95
    Thanks
    3
    Thanked 14 Times in 14 Posts

    Default Re: Pls me out on this arrays number print

    You have your column and row numbers reversed.

    Columns should equal 6 and rows should equal 3

Similar Threads

  1. Print a letter of the alphabet based on a number that is input
    By justlearning in forum What's Wrong With My Code?
    Replies: 1
    Last Post: March 20th, 2013, 01:36 PM
  2. Replies: 9
    Last Post: March 18th, 2013, 05:49 PM
  3. Replies: 4
    Last Post: September 6th, 2012, 05:29 AM
  4. Can't figure out how to print out number of lines and words in a file in c++
    By javapenguin in forum Other Programming Languages
    Replies: 1
    Last Post: January 29th, 2012, 07:53 PM
  5. Replies: 1
    Last Post: October 16th, 2010, 03:32 PM