I want to have a 2 dimentional array

i need a 2 d array or list that i can change size during runtime or at least be able to grow larger but i have no idea exactly what im loking for or how to use it
im going to make a program that each cell is either dead or alive and has health a algorthim controls weather or not more are born or die so if i start with 10 and more are born my array cant be set in stone from the init method
i know i could just make a array of 1000 say but what if i let it run for a few days and it hits 1001 eventually its going to be a ai learning program that each generation of cells gets smarter but
i dont want to get a exeption if it goes over a set number of elements in a regular array

ok this works but when i put it into a html page it cant be instantantiated
so my question is if i just want to make a dynamic 2 d array can i do something like this
int myarray[][];
int temparray[][];
myarray = new int[currentsize_x][currentsize_y];
then later copy all the contents with a pair of for loops into
temparray = new int[i][j];
then make the original array biger and later copy the values back into
myarray = new int[the_new_size][the_new_size];
the use a for loop add in the old values
myarray = new int[i][j];
the code below cant be used because ie needs the html converter and i dont want to use it at this pointin time
import java.awt.*;
import java.applet.*;
import java.util.*;
public class test_arraylist2 extends Applet
int i = 10 ;
int j = 1 ;
int anumber = 5 ;
int dummyvar = 1 ;
ArrayList myarrayB = new ArrayList();
public void init(){    
for(int i = 0; i < 20; i++){
myarrayB.add(new ArrayList()); // add will automatically increment myarrayB
for(int j = 0; j < 20; j++) {    
((ArrayList)myarrayB.get(10)).add( new Integer(anumber)); //auto inc the sublist
     public void paint(Graphics g){ 
     i = 1;
     g.drawString("start of applet) " , 10, 20);
g.setColor(Color.blue);
ArrayList subList = (ArrayList)myarrayB.get(10);
Integer elt = (Integer) subList.get(i); //then get that element out of the sublist
int dummyvar = elt.intValue(); //then get the primitive value out of the element
     g.drawString("output1 === "+ dummyvar, 35, 25*(1+i)+40);
     repaint();

Similar Messages

  • Multi-dimentional array

    I have an multi dimentional array
    it has 5 columns and 8 rows
    A B C D E
    F G H I J
    K L M N O
    P Q R S T
    U V W X Y
    etc
    if i remove the row beginning [1][0]
    how can I get all the ones passed that row to shuffle up to fill the gap?
    A B C D E
    K L M N O
    P Q R S T
    U V W X Y
    ends up as
    A B C D E
    K L M N O
    P Q R S T
    U V W X Y
    Code would be lovely, I am new to this programming lark and I am not sure i like it :'(

    This is something done best (as previously suggested) with collections. Look into the tutorial and APIs for ArrayList and such. However, if you need to use arrays, here is a program that does (rather poorly I would think...)
    public class MultiArrayTest {
        public static void printData(char[][] data, int numRows, int numCols) {
             for (int r = 0; r < numRows; r++) {
                  for (int c = 0; c < numCols; c++){
                       System.out.print("" + data[r][c] + " ");
                  System.out.println(" ");
              System.out.println(" ");
        public static int deleteRow(char[][] data, int row, int maxRows, int maxCols) {
             for (int r = (row-1); r < (maxRows-1); r++){
                  for (int c = 0; c < maxCols; c++) {
                       data[r][c] = data[r+1][c];
             return maxRows-1;
         public static void main(String[] args) {
              char[][] data = { {'A', 'B', 'C', 'D', 'E'},
                                 {'F', 'G', 'H', 'I', 'J'},
                                 {'K', 'L', 'M', 'N', 'O'},
                                 {'P', 'Q', 'R', 'S', 'T'},
                                 {'U', 'V', 'W', 'X', 'Y'} };
              int maxRows = 5;
              int maxCols = 5;
              printData(data, maxRows, maxCols);
              maxRows = deleteRow(data,3,maxRows,maxCols);
              printData(data, maxRows, maxCols);
    }

  • I want to have two different operations on two analog output terminals of DAQ. When I work

    with AO0, it works. But after I add in another channel, AO1, there is an error saying that 'specified group is in use'. Actually, I assigned different group number for AO0 and AO1 when configuing the device using AO Config.vi. How to deal with this error?I want to have two different operations on two analog output terminals of DAQ. When I work with AO0, it works. But after I add in another channel, AO1, there is an error saying that 'specified group is in use'. Actually, I assigned different group number for AO0 and AO1 when configuing the device using AO Config.vi. How to deal with this error?

    with AO0, it works. But after I add in another channel, AO1, there is an error saying that 'specified group is in use'. Actually, I assigned different group number for AO0 and AO1 when configuing the device using AO Config.vi. How to deal with this error?Hey Steve,
    Doug is correct. Both analog outputs have a shared clock. If you want to write to both outputs simultaneously, you will need to include both of them in the same operation (group).
    You can write a 2-D array to the AO Write VI in which you can include data for both channels. In the 2-D array, column 1 will be for the first channel in the channel list and column 2 will be for the second channel.
    I hope this helps.
    Regards,
    Todd D.
    NI Applications Engineer

  • HT1420 How can I get past 5 authorized computers when we have more computers, ipads, iphones than allowed. I want to have parental control by sharing 1 apple ID with one account?

    We have multiple computers, laptops, iphones and ipad in our home. We have kept one account for iTunes in order to monitor what my family downloads for parental monitoring. How can I get approval or allow for more devices to be 'authorized' to purchase from iTunes? I don't want to have to have more than one account that I have to monitor - technology is overwhelming enough to control with all the hackers and distasteful things on the web.

    Authorization applies ONLY to computers.
    ipads/ipods/iphones/apple tvs are NOT authorized at all.

  • How do I delete stored email addresses in my iphone? When sending photos, I don't want to have certain email addresses  "popping up" from the internal memory, I've deleted my entire "Contact" list but they still appear.  Help please!

    How do I delete stored email addresses in my iphone? When sending photos, I don't want to have certain email addresses  "popping up" from the internal memory, I've deleted my entire "Contact" list but they still appear.  Help please!

    As with the Mail app on a Mac, the iPhone's Mail app stores all email recipients in a list of previous recipients which is separate from the address book or contacts. The email address autofill feature when addressing an message pulls from Contacts and from the list of previous recipients.
    Different from the Mail app on a Mac, there is no access to the list of previous recipients with iOS on an iPhone, iPod Touch, or iPad to remove a previous recipient from the list, or to add a previous recipient to the address book or contacts that is not already entered - not at the present time anyway.
    The only way to purge the list of previous recipients at the present time is by restoring your iPhone with iTunes as a new iPhone or not from your iPhone's backup, which will start being re-populated again with every sent message.

  • I just bought an iPod nano 7th gen.  When I connect it to my laptop, it doesn't recognize the ipod.  I tried charging it, but now it won't turn on when i push the power button.  Please help me!  I don't want to have to return it.

    I just bought an iPod nano 7th Generation.  When i connect it to my laptop, it doesn't recognize the ipod.  I tried charging it but when I hold the power button, nothing happens.  I don't want to have to return it.  Please help me!

    Hi dnix257,
    Welcome to the Support Communities!
    What version of the Windows Operating System do you have?
    What version of the iTunes software?
    The troubleshooting steps below may help you with this:
    Apple - Support - iPod nano - iTunes Troubleshooting Assistant
    http://www.apple.com/support/ipodnano/assistant/itunes/#section_1
    iPod not recognized in My Computer and in iTunes for Windows
    http://support.apple.com/kb/TS1369
    Cheers,
    - Judy

  • I want to have application Siri in my phone. Help me. Thanks you

    Hello. I want to have an application Siri in my phone please. Help me please ! Thanks you so much

    There is no Siri application, and Siri is not supported with an iPhone 4. You need a 4S or later.

  • What do i need to connect my mac book pro to the tv with the thunderbolt on the mac to hdmi? I have the newest macbook pro. I'm wanting to have the best picture I can get from my 1080p tv. thanks

    what do i need to connect my mac book pro to the tv with the mac's thunderbolt port to hdmi? I have the newest macbook pro. I'm wanting to have the best picture I can get from my 1080p tv. thanks

    Thanks Community! I solved the problem. In fact it was not a problem but lack of understanding. These guys at Apple are way ahead in thir thinking. I will try to explain as short as I can.
    In Lion, ihe Prefferences/Display show only two choices: 6-7 steps of resolution and some color tab. No two screens, no two display to overlap, nothing for us to do. "That was the problem"! Everything is automatic.
    When I connected the HDMI cable to the Miniport into a T-bolt slot, the TV screen showed the "spiral galaxy" how Zyriab is calling it. In fact he gave me the best clue. That shows the connection is good. But where is the Mac Book image?
    You have to drag it to the right out of the Mac Book display area, and "voila!" it will continue on the TV screen. The same with the mouse pointer, push it out ofthe Mac Book display area and you see it on the TV sreen. Good image, you can keep the max resolution, etc. The sound is still on the Book's speakers. I have to figure that out.
    Thank everybody, especialy Zyriab, ne was the closest.
    High regards to everybody

  • I have an iTunes account with my own music library.  My wife wants to have her own music library.  Is there a way of setting up a sub account for her, or do I have to set of husband playlists and a separate set of wife playlists?

    I have an iTunes account with my own music library.  My wife wants to have her own music library.  Is there a way to set up a sub account for her, or do I have to set up a set of husband playlists and a set of wife playlists?

    Sorry, but that's not possible.
    You can share iTunes libraries on a network >  iTunes: Setting up Home Sharing on your computer

  • I have itunes on one computer. my account says that I have 2 computers authorized. I want to have itunes on both users accounts on my computer. how do I do this? thanks for any help!

    I have itunes on my computer in my main user account. I want ot have the same itunes on the other user account on my computer - under the apple account info- it says that I already have 2 computers authorized - how do I find out which 2 they are talking about?  the only button nearlby is one that says to 'deauthorize all' etc.... thanks,. I have a pc.

    You can only deauthorize all your itunes computers once a year, so I would avoid clicking that at the moment.  Log onto the 2nd user, and open itunes.  Go to Store> Authorize This computer.
    As an alternative, you could point the 2nd user itunes library to the primary itunes folder.  So both users would use the same itunes folder.  You can do this by holding shift, clicking itunes icon.  There should be an option to browse for an existing library.  Locate the main computers itunes folder. (Most likely under: C:\Users\*Account name*\Music where *Account name* would be your main user accounts name.
    Good luck!

  • How do I transfer my bookmarks from one computer to another? I have Firefox Home on my phone and I can get them there, but I want to have the same bookmarks on my home computer as I do on my work computer.

    How do I transfer my bookmarks from one computer to another? I have Firefox Home on my phone and I can get them there, but I want to have the same bookmarks on my home computer as I do on my work computer. If I have a user name then where do I sign into Firefox, it should be that easy but I can't seem to figure it out.

    Hey susanneyes,
    Sounds like you want to set up Firefox Sync. This will allow you to keep all of your instances of Firefox synchronized. Just follow the steps in [https://support.mozilla.com/en-US/kb/what-firefox-sync?s=sync&r=0&as=s this article] and you'll be set.
    Hopefully this helps!

  • I have been using my husband's apple id in my old PC. When I purchased a MacBook Pro, I created my own. Because I wanted to have access to my old purchases, I changed my husband's original ID's e-mail address to my e-mail address. Now I can't update s/w.

    I have been using my husband's apple id in my old PC (ID A). When I purchased a MacBook Pro, I created my own Apple ID (ID B) and started using my laptop and updating the S/W with this ID.
    Because I wanted to have access to my old purchases, I changed my Apple ID's e-mail to another e-mail that my husband uses (ID B->ID C).
    Then I changed my husband's original Apple ID's e-mail address to my own e-mail address (ID A->ID B).
    Now I can't update any s/w through the Apple Store and I get the message that "Sign in to **********@hotmail.com to update applications for that account.". The e-mail address is ID C. How can I associate my laptop in the AppStore with ID B which is the one that have all my purchased applications and contains my own e-mail address?
    I would appreciate your reply.
    Dimitra

    You are trying to find a loophole to circumvent a basic rule that prohibits the transfer of purchased content from one Apple ID to another.
    Content tied to an Apple ID are bound to that Apple ID forever. You can not merge or trade accounts. Well, not (officially) anyway...

  • My Daughter has an Ipod and when I set up the account before giving her the gift for Xmas I set it up under my email address, now I have an iphone 4 and I want to have my own account for itunes. Is there any way 2 do this w/ two separate accts, same email

    My daughter got an Ipod for Xmas and I set up the apple account before hand & used my email address to set it up, now I have purchased an Iphone 4 and I want to have a separate itunes for my music.... is there a way to have two separate itunes accounts under the same email address?

    Thanks.  I have my iPad on my lap and her iPod in my hand. We can FaceTime each other but it won't let either of us message each other. I know mine is activated as I use it frequently. I have activated hers as well. Maybe I will put it in the too hard basket for tonight, sleep on it and try again tomorrow.

  • I have been sharing my iTunes account with my kids...now they are getting older and want to have their own accounts, how do I share the songs I purchased for them on my account with them on their new accounts?

    I have been sharing my iTunes account with my kids...now they are getting older and want to have their own accounts, how do I share the songs I purchased for them on my account with them on their new accounts?  Is there a way to transer from my main account their new accounts?  And can I share music from my account with them?

    You can't currently transfer content from one account to another account. As long as the tracks are on the computer's iTunes that they use/sync to, and your account is authorised on that iTunes, then they should be able to continue to use them.

  • I am receiving a new ipad (3 i guess) from my mom who is in the U.S but i am currently in the philippines. I ofcourse, want to have apps,games,movies etc. can i use an itunes giftcard (also from the U.S) to buy my apps without any problems?

    i am receiving a new ipad (3 i guess) from my mom who is in the U.S but i am currently in the philippines. I ofcourse, want to have apps,games,movies etc. on it. can i use an itunes giftcard (also from the U.S) to buy my apps without any problems?

    No.
    iTunes terms of service:
    The iTunes Service is available to you only in the United States, its territories, and possessions. You agree not to use or attempt to use the iTunes Service from outside these locations. Apple may use technologies to verify your compliance.

Maybe you are looking for

  • Printing Password NO LONGER WORKS with Snow Leopard!

    Ive searched this forum and most people have the opposite problem I do. They want to disable password requests when printing, but I want them! With Leopard, I was able to set up our networked color printer on every mac and students who logged in with

  • Burning NTSC vs. PAL

    I have moved a great deal of my DVD library into iTunes and have never cared about NTSC v PAL. However, I may be moving from the US to a country where PAL is the standard. What should I be worried about? Are the videos in my library going to be usabl

  • Sync videos to Ipod

    I've recently downloaded some music videos from youtube to my Itunes account,they're in my RECENTLY ADDED and Movies, I can play them on my pc just fine, but they're not syncing to my Ipod touch.Pleeeeeese tell me what to do. Thank you all.

  • AOL Compatible with Mac OC X 10.5?

    I started from a clean install on my Alum iMac. Logged on to AOL via Safari and read mail with no problems. I then downloaded AOL software 10.3.7 Rev 4136.310 US. Then proceeded to set up my account. Sign on was normal but when I go to Preferences to

  • Invoking winapi functions

    hi all can i call winapi functions in form 9i as it can be in VB. If yes can any one give me at least one example , suppose i want to shutdown my pc. thanks