Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Help with arrays and objects?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
fenixconnexion




PostPosted: Wed May 02, 2007 8:30 pm   Post subject: Help with arrays and objects?

hey guys im a newb at java and i have a test tomorrow so any help would be greatly appreciated,
in a 2 dimensional array:

int [][]list = new int [5][4];
what would i use to find the length of the rows, the length of the colums, and how would i write a program to "pop" all the objects off? thanks!
Sponsor
Sponsor
Sponsor
sponsor
fenixconnexion




PostPosted: Wed May 02, 2007 8:32 pm   Post subject: RE:Help with arrays and objects?

ALSO:

this is a question in my book:

how much space in bytes would b required to store teh elements of the arrays created by the following declarations?

a) double [] a = new double [10]

how would i solve this?

thanks
Reality Check




PostPosted: Mon May 07, 2007 10:05 pm   Post subject: Re: Help with arrays and objects?

Think of a 2-D array as an Array within an array, a checkerboard if you will. While an array is a bus, a 2-D array is a double decker.

Anyways, to get the length of the row you simply use the line: "arrayName.length"

To get the length of the array within each array you use: "arrayName [row].length"

Using this we can use a for loop within a for a loop and come up with this:

code:

for (int row = 0; row < arrayName.length; row += 1)
{
    for (int column = 0; column < arrayName [row].length; column +=1)
       {
            System.out.println (arrayName[row][column])
        }
}
fenixconnexion




PostPosted: Thu May 24, 2007 12:11 pm   Post subject: RE:Help with arrays and objects?

^^^ thank you very much!!!
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 4 Posts ]
Jump to:   


Style:  
Search: