Forums Register Login

cant understand arrays

+Pie Number of slices to send: Send
Assume the code,


int a[][]=new [2][]; // no error compiles successfully;


What dimension I am putting and in what conditions it will run successfully. Please help me


Thanks
[ July 22, 2008: Message edited by: Bear Bibeault ]
+Pie Number of slices to send: Send
"Venkattesh B", please check your private messages for an important administrative matter.
+Pie Number of slices to send: Send
seems like you have learned C/C++ language & you are thinking in those terms.
in java if you were to declare
int [][][] arr = new int[2][][];
it will run properly as it requires atleast one, that is the highest dimension of the array to be created.
the rest you can leave it blank. you can assign as and when you require
arr[0] = new int[3][];
arr[1] = new int [5][4];

the arrays need have all its dimensions the same length!!
arr[0].length is 3
arr[1].length is 5
arr.length is 2
You will always be treated with dignity. Now, strip naked, get on the probulator and hold this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 647 times.
Similar Threads
How do I become Employabe?
"create" doesnt add record to the database!
Novice in JDBC
how to display data in dropdown box from database using java code
examples on webservices
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 01:53:01.