File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes how to use array in array? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to use array in array?" Watch "how to use array in array?" New topic
Author

how to use array in array?

sathiya moorthy
Greenhorn

Joined: Nov 27, 2004
Posts: 9
int a[] = {1, 2, 3};
int b[] = {4, 5, 6};
int c[] = {7, 8, 9};

Object arr[] = new Object[4];
arr[0] = a;
arr[1] = b;
arr[2] = c;
i have arrays like this, now i want to print the values of array a,b,c from the array arr
can any one help me please
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
HTH


[ April 06, 2005: Message edited by: Srinivasa Raghavan ]

Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
Yosi Hendarsjah
Ranch Hand

Joined: Oct 02, 2003
Posts: 164
Something's not right in Srini's code. Can you see it?

Here's mine:

[ April 06, 2005: Message edited by: Yosi Hendarsjah ]
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Hi dude it's just an example code.
See the value of d[] is initilized to arr[0].



Basically i thought sathiya moorthy needs to know the concept of casting an array from Object. Hence the code depicting this line "int d[] = (int[]) arr[0];" gets the int[] from the Object[] .
[ April 06, 2005: Message edited by: Srinivasa Raghavan ]
Yosi Hendarsjah
Ranch Hand

Joined: Oct 02, 2003
Posts: 164

Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Yep it's a typo i have changed it ..
Yosi Hendarsjah
Ranch Hand

Joined: Oct 02, 2003
Posts: 164
Originally posted by Srinivasa Raghavan:
Yep it's a typo i have changed it ..

My point is, to be a good programmer you have to be meticulous.

BTW, in programming, it's not called a typo. It's called a bug.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to use array in array?