Compile following code for Android:
public class MainActivity: Activity {
public override void onCreate(Bundle savedInstanceState) {
base.onCreate(savedInstanceState);
ContentView = R.layout.main;
}
private class NestedClass{
}
}
Then decompile it to check the generated Java code:
public class MainActivity extends Activity {
private class NestedClass {
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}}
I find the NestedClass is a non-static inner class in Java. As we know, nested class in C# won’t capture its outer class, so the equivalent one in Java should be static inner class which is more efficient.