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

sierra/bates ch.4 self test, question #2

 
Rachel Glenn
Ranch Hand
Posts: 95
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
given the code segment:



and the test for equality...




Is the reason the equality test COMPILES because f3 and f2[2] are considered object references? I initially thought this might not compile because the array sizes were different.
 
Enkita mody
Ranch Hand
Posts: 333
Firefox Browser Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
R Gle wrote:given the code segment:



and the test for equality...




Is the reason the equality test COMPILES because f3 and f2[2] are considered object references? I initially thought this might not compile because the array sizes were different.


Yes.You're comparing their address not any element.


-hth
 
Praveen Kumar M K
Ranch Hand
Posts: 256
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
R Gle wrote:given the code segment:



and the test for equality...




Is the reason the equality test COMPILES because f3 and f2[2] are considered object references? I initially thought this might not compile because the array sizes were different.


f2 is an array of arrays, therefore the individual elements within this collection should also be arrays, correct? So when you access f[2] you are accessing an array at the 2nd position, so it should compile.
How about trying if(f2 == f3) {}?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic