• Post Reply Bookmark Topic Watch Topic
  • New Topic

array declaration  RSS feed

 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all

after b is initialized in line 2 ,the 1st and 2nd row of b contains 3 column.in line 3 how is it possible to change the length of only 1st row.isn't it that once the size of array declared cannot be changed?
Thank you
 
Darryl Burke
Bartender
Posts: 5167
11
Java Netbeans IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're not changing the size of an array at all. int[][] declares an array of int[] elements. When you say b[0]=a, you are assigning a different array to the first element of b.

The int[] array of size 3 which was earlier referenced from b[0] becomes eligible for garbage collection.
 
Gajendra Kangokar
Ranch Hand
Posts: 94
1
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohh yes!! thanks
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!