I need some help solving the following problem, can anyone assist?
this is what is needed to be done:
public class Base { private static final int ID = 3; private String name = "Henry"; public void methodA( final int nn ) { int serialN = 11; class inner { void showResult() { System.out.println( "ID = " + ID ); } } new inner().showResult(); } public static void main (String[] args) {
} }
i need to Modify the main method so that it calls methodA to display the output.
then,
Add another inner class to methodA with a method to display the values of the name and nn variables. I need to make sure that methodA invokes this new method.
last,
i need to create another program that does the same thing as this one, and that also has separate main, methodA, and showResult methods but that doesn't use nested classes.
publicclass Base{
privatestaticfinalint ID = 3;
private String name = "Henry";
publicvoid methodA( finalint nn ) {
int serialN = 11;
class inner {
void showResult() {
System.out.println( "ID = " + ID );
}
}
new inner().showResult();
/** another inner class to methodA with a
* method to display the values of the
* name and nn variables. I need to make
* sure that methodA invokes this new method.
*/
class inner2 {
void showResult() {
System.out.println("name = " + name);
System.out.println("nn = " + String.valueOf(nn));
}
}
new inner2().showResult();
}
publicstaticvoid main (String[] args){
Base base = new Base();
/* call methodA to display the output */
base.methodA(33);
}
}