Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

illegal array reference assignments

 
sonia jaswal
Ranch Hand
Posts: 42
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. 1-D array cannot be assigned to a 2-D array.
2. Nonarray object cannot be assigned to a 2-D refernce.
3. Nonaraay object cannot be assigned to a 1-D array reference.
4. Array Object cannot be assigned to a nonarray reference.

Can anybode please help me out in understanding these exception with an example....???
 
Phani Burra
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1. 1-D array cannot be assigned to a 2-D array.
int[][] x;
int[] y;
Assuming the y has been initialised with some int values
x=y; gives type mismatch error cannot convert from int[] to int[][]
but x[0]=y; is correct.

2. Nonarray object cannot be assigned to a 2-D refernce.
3. Nonaraay object cannot be assigned to a 1-D array reference.
4. Array Object cannot be assigned to a nonarray reference.

2,3,4 are obvious because you cannot assign a String object to an Array reference and cannot assign Array obj to a String reference.Hope this info helps
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic