Given the following code:
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");
//...
What can I swap out with my pseudo-code line so that I can compare the values of n for the two instances of the Inner class?
Trying the obvious solution (n != that.n
) doesn't compile:
Outer.java:10: cannot find symbol
symbol : variable n
location: class Outer.Inner
if (n != that.n) // pseudo-code line