Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to use array in array?

 
sathiya moorthy
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HTH


[ April 06, 2005: Message edited by: Srinivasa Raghavan ]
 
Yosi Hendarsjah
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

 
Srinivasa Raghavan
Ranch Hand
Posts: 1228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep it's a typo i have changed it ..
 
Yosi Hendarsjah
Ranch Hand
Posts: 166
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic