wood burning stoves 2.0*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Assigning array references Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Assigning array references" Watch "Assigning array references" New topic
Author

Assigning array references

Arthur Blair
Ranch Hand

Joined: Sep 20, 2005
Posts: 71
So... reading the K+B book.

If you assign an array to a previously declared array reference, the array you're assigning must be the same dimension as the reference you're assigning it to.

so why does this compile corectly?



What am I doing wrong here?
Thoughts appreciated.
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
Your arrays are of a different size, not of a different dimension. They are all one dimensional int arrays. The dimension of an array is the number of indexes required to locate an element.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
David Rowland
Greenhorn

Joined: Jan 17, 2006
Posts: 5
"dimensions" refers to the number of sets of brackets the array has, to put it simply.

int[] oneDimensional = new int[x][y]; //illegal
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Assigning array references