
-----------------------------------
uberwalla
Fri Feb 22, 2008 7:34 pm

How to store arrays in an array? kind of?
-----------------------------------
Ok i am not trying to make a 2 dimentional array. just trying to be able to call on other arrays using an array.

basically what i want to do is have some arrays:


String 

Thats basically what i want to do (call the arrays from that 'all' array. but i keep getting the errors:


roman.java:54: incompatible types
found   : java.lang.String

any idea how i can make this work?

-----------------------------------
[Gandalf]
Fri Feb 22, 2008 7:48 pm

RE:How to store arrays in an array? kind of?
-----------------------------------
That doesn't make sense.  You have 4 arrays of Strings which you are then treating as individual Strings when initializing the all array.  Choose either to have ones, tens, hundreds, and thousands as Strings or else make the all array 2-dimensional.

You'll have to give more info on the problem if you're trying to avoid multi-dimensional arrays.  What exactly do these Strings/arrays contain?  At first glance it looks like you're over complicating the matter in the first place.

-----------------------------------
richcash
Fri Feb 22, 2008 7:56 pm

Re: How to store arrays in an array? kind of?
-----------------------------------
String [] [] all = new String [4] [10];
But you'll have to make your thousands array the same length as the others if you want to make an array of arrays, right?

-----------------------------------
uberwalla
Fri Feb 22, 2008 8:00 pm

Re: How to store arrays in an array? kind of?
-----------------------------------
these arrays are containing a bunch of roman numerals as such:


		String 

i want the all array:


		String 

to hold those other arrays so i can run something like:


        numstr = number.toString();
	length = numstr.length;
	romanstr = '';

	for (i = 0; i < length; i++) {
		romanstr += all

I am also not sure if this is possible in java or not as i am trying to convert an old javascript program i have to plain java. (so yes i know some of those commands aren't actually pure java commands)

so basically is there a way i can recreate that into java? so that i can convert a integer a roman numeral (that's what i am making this program for)

If you need more info still. I can try to explain what I am trying to achieve better.

thanks,
uber~

-----------------------------------
OneOffDriveByPoster
Fri Feb 22, 2008 8:48 pm

Re: How to store arrays in an array? kind of?
-----------------------------------
String[][] all = new String [4][];

-----------------------------------
wtd
Sat Feb 23, 2008 2:12 am

RE:How to store arrays in an array? kind of?
-----------------------------------
Don't use arrays?  Collections are your friend?

-----------------------------------
Aziz
Sat Feb 23, 2008 12:51 pm

RE:How to store arrays in an array? kind of?
-----------------------------------
Doing it with arrays:

When you declare an array as StringType

Type is the type of each element in the array
 declares that it's an array. Together these declare an array type.

So to make and array of arrays (which is what a mulitdimensional array is in Java, by the way), you make the type an array. And an array type is Typejagged array in some languages where there are different array types (like C#)

-----------------------------------
uberwalla
Sat Feb 23, 2008 1:53 pm

Re: How to store arrays in an array? kind of?
-----------------------------------
i have actually solved the problem from earlier. thanks a lot though guys. seems i did need to declare all as [] [].

i thought it was just going to be a multidimentional array like in javascript which wouldn't have worked for what i was trying to do. but indeed it did work because i needed the second array parameter to call on the other arrays. 

thanks to all those who helped.

-----------------------------------
Aziz
Sat Feb 23, 2008 4:58 pm

RE:How to store arrays in an array? kind of?
-----------------------------------
Good. Make sure you understand what you're doing, too and why it works. I hate to sound like wtd, but that's more important then getting it to work (especially in an academic environment)

-----------------------------------
uberwalla
Sat Feb 23, 2008 5:03 pm

Re: How to store arrays in an array? kind of?
-----------------------------------
yea i understand how it works. i needed the extra array in it to act as a means of calling the other arrays. because i was trying to call ones not ones []
