次のコードが与えられます:
public class Outer
{
public final int n;
public class Inner implements Comparable<Inner>
{
public int compareTo(Inner that) throws ClassCastException
{
if (Outer.this.n != Outer.that.n) // pseudo-code line
{
throw new ClassCastException("Only Inners with the same value of n are comparable");
//...
Innerクラスの2つのインスタンスのnの値を比較できるように、擬似コード行と何を交換できますか?
明らかな解決策()を試してn != that.n
もコンパイルされません:
Outer.java:10: cannot find symbol
symbol : variable n
location: class Outer.Inner
if (n != that.n) // pseudo-code line