Skip to content

Instantly share code, notes, and snippets.

@libliboom
Last active November 4, 2019 07:25
Show Gist options
  • Save libliboom/d64972ed0dcb8cb080fb93b271882f17 to your computer and use it in GitHub Desktop.
Save libliboom/d64972ed0dcb8cb080fb93b271882f17 to your computer and use it in GitHub Desktop.
class ExchangeRate {
private int CountryCode;
public void b() {
Info info = new Info();
int d = info.day;
int m = info.month;
int y = info.year;
}
public class Info {
public int day;
/*package*/ int month;
private int year;
public Info() {}
public void setDay(int day) {
this.day = day;
}
public void a() {
int code = CountryCode;
}
}
}
public class InnerClassEx {
public static void main(String[] args) {
// possible
ExchangeRateEx.Info info = new ExchangeRateEx().new Info();
info.setDay(0);
System.out.println(info.day);
// java.lang.NoSuchMethodException: map.ExchangeRate$Info.<init>()
try {
ExchangeRateEx.Info.class.getConstructor(new Class[0]);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment