aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes illegal array reference assignments Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "illegal array reference assignments" Watch "illegal array reference assignments" New topic
Author

illegal array reference assignments

sonia jaswal
Ranch Hand

Joined: Jun 01, 2007
Posts: 42
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

Joined: Dec 13, 2007
Posts: 52
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
 
Consider Paul's rocket mass heater.
 
subject: illegal array reference assignments