How can I use two dimensional array ?

Could some one show me how to use two dimentional array ?
I am know how to right a single ...but not two dimentional....please help,
Thanks,
Flower
public class Exam5
public static void main(String[] args)
int[][] numbers =
     {     {1,2,3,4,5,6,7,8,9,10},
{1,2,3,4,5,6,7,8,9,10} };
for(int i = 1; i < 11; ++i)
System.out.println(i + "\t" + i * 2 + "\t" + i * 3 + "\t" + i * 4 + "\t" + i * 5 +
"\t" + i * 6 + "\t" + i * 7 + "\t" + i * 8 + "\t" + i * 9 + "\t" + i * 10);
Display #
1     2     3     4     5     6     7     8     9     10
2     4     6     8     10     12     14     16     18     20
3     6     9     12     15     18     21     24     27     30
4     8     12     16     20     24     28     32     36     40
5     10     15     20     25     30     35     40     45     50
6     12     18     24     30     36     42     48     54     60
7     14     21     28     35     42     49     56     63     70
8     16     24     32     40     48     56     64     72     80
9     18     27     36     45     54     63     72     81     90
10     20     30     40     50     60     70     80     90     100

First, try not to ask someone to do your homework for you and then tell them they are wrong. The code posted may not have been exactly what you were looking for, but it was not wrong because it did exactly what the poster said it would do - print out the multiplication table.
Second, in the future if you ask specific questions rather than posting code and hoping someone will fix it for you, you may one day be able to complete the assignments on your own.
Here is code that prints what you want and uses a two dimensional array. Please ask questions if you do not understand the code. You will never learn if you just use someone else's code without taking the time to examine or understand it.
public class MultiTable{  
    public static void main(String[] args)   { 
        int rows = 10;
        int columns = 10;
        int [][] numbers = new int [rows] [columns];
        for(int j = 0; j < rows; j++)   // for each of 10 rows
            for(int k = 0; k < columns; k++)    // for each of 10 columns
                numbers[j][k] = (j+1) * (k+1);  // calculate row+1 * col+1
        for (int j = 0; j < rows; j++)  // for each of 10 rows
            for (int k = 0; k < columns; k++)   // for each of 10 columns
                System.out.print(numbers[j][k]+" ");    // print out result
                if (numbers[j][k] < 10)     // for single digit numbers
                    System.out.print(" ");  // print extra space for better formatting
            System.out.println();       // skip to next line
}

Similar Messages

  • How can I do two dimensional arrays?

    I am a C++ programmer and in C++ I am able make a two dimensional array and input the values that correspond to those cells.
    After I saw the proposals that you (experts) made I am going to share a little of the classified information that I was working for the undefeatable XO game.
    First step:My idea was to make a two dimensional array(in C++ we use the following syntex for two dimensional array{array[i][j]})
    I was wondering if I am able to make a two dimensional array using LABVIEW .
    Second step: Store the values of X or O inside the 2D array.And use maybe boolean variables(in C++ we use inaddition to that if statement).
    My second question :What can I do inorder to minimize the number of boolean vaariables?(also if statements in C++)
    Jupiter
    extinct when hell froze over

    This is a subroutine I use to check for a winner in a XO game.
    While playing, the main code replaces default 0's by 1's inside the 2D array of a single player.
    Then the main code calls this VI with the 2D array of that player and check for a winning game.
    Any board size is ok as long as you have equal number of cols & rows.
    So, enter 1's at any location in the "Score" 2D array and the code will check for a winning game.
    As you can see I don't use any boolean variables, except the return value of this VI (read function) 
    So to answer your second question; I minimized the use of boolean variables to 0 1! Is that ok for you?
    Attachments:
    TTT-Check4Winner.vi ‏20 KB

  • How to use two dimensional array in custom.pll

    HI
    How to use two dimensional arrays in custom.pll
    I tried by the following way .
    type ship_array is table of number index by binary_integer;
    type vc_array is table of ship_array index by binary_integer;
    But I am getting the error as that
    A plsql table may not contain a table or a record with composite fields.
    Please tell me the way how to use them

    which forms version are you using? two dimensional arrays are available in >= 9i if memory serves.
    regards

  • How Can i Use two Different Public IP Addresses no my DMZ with ASA Firewall.

    How To Using Two Different Public IP Address on My DMZ with ASA 5520
    Postado por jorge decimo decimo em 28/Jan/2013 5:51:28
    Hi everyone out there.
    can any one please help me regarding this situation that im looking for a solution
    My old range of public ip address are finished, i mean (the 41.x.x.0 range)
    So now i still need to have in my DMZ another two servers that will bring some new services.
    Remember that those two server, will need to be accessable both from inside and from outside users (Internet users) as well.
    So as i said, my old range of public ip address is finished and we asked the ISP to gives some additional public
    ip address to address the need of the two new servers on DMZ. and the ISP gave us the range of 197.216.1.24/29
    So my quation is, on reall time world (on the equipment) how can i Use two different public ip address on the same DMZ
    on Cisco ASA 5520 v8??
    How my configuration should look like?
    I was told about implementing static nat with Sub Interfaces on both Router and ASA interface
    Can someone please do give me a help with a practical config sample please. i can as well be reached at [email protected]
    attached is my network diagram for a better understanding
    I thank every body in advance
    Jorge

    Hi,
    So looking at your picture you have the original public IP address range configured on the OUTSIDE and its used for NAT for different servers behind the ASA firewall.
    Now you have gotten a new public IP address range from the ISP and want to get it into use.
    How do you want to use this IP address range? You want to configure the public IP addresses directly on the servers or NAT them at the ASA and have private IP addresses on the actual servers (like it seems to be for the current server)?
    To get the routing working naturally the only thing needed between your Router and Firewall would be to have a static route for the new public network range pointing towards your ASA OUTSIDE IP address. The routing between your Router and the ISP core could either be handled with Static Routing or Dynamic Routing.
    So you dont really need to change the interface configuration between the Router and ASA at all. You just need a Static route pointing the new public IP address towards the ASA outside IP address.
    Now when the routing is handled between the ISP - ISP/Your Router - Your Firewall, you can then consider how to use those IP addresses.
    Do you want to use the public IP addresses DIRECTLY on the HOSTS behind the firewall?This would require you to either configure a new physical interface with the new public IP address range OR create a new subinterface with the new public IP addresses range AND then configure the LAN devices correspondingly to the chosen method on the firewall
    Do you want to use the public IP addresses DIRECLTY on the ASA OUTSIDE as NAT IP addresses?This would require for you to only start configuring Static NAT for the new servers between the inside/dmz and outside interface of the ASA. The format would be no different from the previous NAT configuration other than for the different IP addresses ofcourse
    Of the above ways
    The first way is good because the actual hosts will have the public IP addresses. Therefore you wont run into problems with DNS when the LAN users are trying to access the server.
    The second way is the one requiring the least amount of configurations/changes on the ASA. In this case though you might run into problem with DNS (to which I refer above) as the server actually has a private IP address but the public DNS might reply to the LAN hosts with a public IP address and therefore connections from LAN could fail. This is because LAN users cant connect to the servers OUTSIDE NAT IP address (unless you NAT the server to public IP address towards LAN also)
    Hopefully the above was helpfull. Naturally ask more specific questions and I'll answer them. Hopefully I didnt miss something. But please ask more
    I'm currently at Cisco Live! 2013 London so in the "worst case" I might be able to answer on the weekend at earliest.
    - Jouni

  • How can I use two accounts ?

    How can I use two accounts (mine and my wife's) to PhotoStream to my mac? I have to turn off photo stream for one or the other...can't I just leave two accounts logged on so that the photos from my iphone and hers both go to my mac?

    Photostreaming across machines requires to use the same Apple-ID on all of these machines or devices. Share all of iclouds account stuff or nothing at all . No way around as icloud is designed that way. Photostream is not designed as a sort of gallery to share with outsiders. It is for your personal entertainment .

  • How can I use two monitors to increase workspace?

    how can I use two monitors to increase workspace?

    Drag the tabs of any After Effects windows you want to the second monitor.

  • How can we use two BOM

    Dear all,
    my scenario is in this way way-
    how can we use two BOM for same material.first BOM for inhouse production. Second one for Subcontracting.(means i have to create Purchase order for partial qty.

    Dear
    1.Goto MM02-MRP4 view -Maintain two Production Version based on two BOM ( Alternative1 with Routing will be PV1 will be used for production in house  where as Alt2 with routing having PP03 as control key for external operation -PV2 )
    2.Assign the relavant production Version-PV2 in Subcontracting Info Record in ME11
    Now, based on the production version assigned in Info Record system suggests the BOM while BOM explosion in Subcon Purchase Order
    REFER : Subcontracting & BOM  alternative
    Hope this will solve your issue
    Regards
    JH
    Edited by: Jiaul Haque on Sep 29, 2010 1:27 PM

  • How can I use two different Yahoo mail accounts ion Firefox?

    I have two Yahoo mail IDs. How can I use them both simultaneously on Firefox? Right now I am running Firefox and Internet Explorer so I can have the two accounts open at the same time. I would prefer to have both accounts running on Firefox, but I can't figure out how to do it.

    Multifox is an extension that allows Firefox to connect to websites using different user names. Simultaneously! <br />
    http://br.mozdev.org/multifox/

  • How can I use two displays with my Mac Mini?

    How can I connect two displays to my Mac Mini (newest generation with one thunderbold and one hdmi)?

    Have you tried connecting one to the HDMI output, and another to the Thunderbolt port (with the appropriate Mini DisplayPort-to-other connection adapter as needed)?

  • How can I use two database in Dataset in SSRS?

    Hi,
    I am using one query to generate my SSRS report. In that query I am using subquery. Now I am pulling data from multiple tales.
    DB used in sub query is different than the rest of the tables DB.(So total I am using 2 DB(Database))
    So I see that in SSRS, I can connect query(In DataSet Properties) to one DATA_SOURCE only, how can I use other database which is I used in sub-query?
    I have to move this SSRS into PROD and I can't hard code that sub-query's DB name in my query.
    Please give me suggestion. Thanks!!
    Vicky

    In SSRS 2008 R2 you can use the Lookup function (http://technet.microsoft.com/en-us/library/ee210531.aspx ) and LookupSet function (http://technet.microsoft.com/en-us/library/ee240819.aspx
    Depending on your security set up, you can reference a table in a second database on the same server using a three part name:  database.schema.table.  This is more likely to work for you if you wrap your SQL command in a stored procedure.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • How can I use two differant iphones on one itunes

    I can i use two differant iphones on one itunes, and keep the content seperate?

    You can sync as many iphones/ipod/ipads as you like to one computer.
    Each is different and is recognized as such

  • How can I use two Airport Express N's together

    I have just purchased the new airport express n and I have the one that I am currently using which is also an n.
    How can I use both at the same time as part of the same network?

    If your goal is to extend the wireless range of one AirPort with another, check out this Apple Support article.

  • How can I use two single-dimensional arrays-one for the titles and array

    I want to Use two single-dimensional arrays-one for the titles and one for the ID
    Could everyone help me how can i write the code for it?
    Flower
    public class Video
    public static void main(String[] args) throws Exception
    int[][] ID =
    { {145,147,148},
    {146,149, 150} };
    String[][] Titles=
    { {"Barney","True Grit","The night before Christmas"},
    {"Lalla", "Jacke Chan", "Metal"} };
    int x, y;
    int r, c;
    System.out.println("List before Sort");
    for(c =0; c< 3; ++c)
    for(r=0; r< 3; ++ r)
    System.out.println("ID:" + ID[c][r]+ "\tTitle: " + Titles[c][r]);
    System.out.println("\nAfter Sort:");
    for(c =0; c< 3; ++c)
    for(r=0; r< 3; ++ r)
    System.out.println("ID:" + ID[c][r]+ "\tTitle: " + Titles[c][r]);

    This is one of the most bizarre questions I have seen here:
    public class Video
    public static void main(String[] args) throws Exception
    int[] ID = {145,147,148, 146,149, 150};
    String[] Titles= {"Barney","True Grit","The night before Christmas", "Lalla", "Jacke Chan", "Metal"};
    System.out.println("List before Sort");
    for(int i = 0; i < Titles.length; i++)
       System.out.println("ID:" + ID[i]+ "\tTitle: " + Titles);
    System.out.println("\nAfter Sort:");
    for(int i = 0; c < Titles.length; i++)
    System.out.println("ID:" + ID[i]+ "\tTitle: " + Titles[i]);
    Generally you don't use prefix (++c) operators in you for loop. Use postfix (c++).
    Prefix means that it will increment the variable before the loop body is executed. Postfix will cause it to increment after.

  • How can I use two screens to display one window

    Before Mavericks, MAC OS allowed you to use two screens (next to each other) in order to display one (big) window of one application.
    That would mean that a window would start on your left screen en would continue on the right screen.
    With Mavericks, however, this not possible any more. The window of the application can only be seen on ONE of the screens (i.e. the left one).
    Can any one tell me whether I've missed certain options or how to adjust my settings in order to get this feature back?

    Hey CGNL,
    First, if you haven't already, set up the displays as an extended desktop:
    Choose Apple menu > System Preferences, click Displays, then click Arrangement.
    Follow the onscreen instructions.
    Then, use Mission Control preferences to uncheck/turn off the option for "Displays have separate Spaces":
    Choose Apple menu > System Preferences, click Mission Control
    Uncheck "Displays have separate Spaces"
    That should enable you to stretch whatever window you want across multiple displays.
    via: OS X Mavericks: Connect multiple displays to your Mac
    http://support.apple.com/kb/PH13814
    and
    OS X Mavericks: Mission Control preferences
    http://support.apple.com/kb/PH13925
    Welcome to Apple Support Communities!
    Have a good one,
    Delgadoh

  • How can I use two ports in the same time?

    My application need one pc use two ports the same time.But when I open one port and my systerm is running the other port can't be opened.
    I use the frame API in VC++6.0.
    My OS is win2000 server;
    The functions I used are ncOpenObject();

    Hi DickW
    Thank you for your help!
    I have tried the example.But the example shows how to connect one CAN network with two ports.
    I want each port connect to the net can both read and write;
    I want to apply the function like this:
    1.config the port1 and port2
    2,open port1 and port2
    But after I open port1 or port2 the other port can't be opened;
    After I open the second port it always returns negative.
    In the codes I use CAN0 and CAN1 as the CAN objects.
    Attachments:
    twoport.zip ‏1184 KB

Maybe you are looking for