The Artima Developer Community
Sponsored Link

Java Answers Forum
methods

1 reply on 1 page. Most recent reply: Apr 12, 2003 5:44 PM by Charles Bell

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
anthony hutchinson

Posts: 5
Nickname: hutchae1
Registered: Apr, 2003

methods Posted: Apr 12, 2003 12:53 PM
Reply to this message Reply
Advertisement
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.

it is greatly appreciated..


ant


Charles Bell

Posts: 519
Nickname: charles
Registered: Feb, 2002

Re: methods Posted: Apr 12, 2003 5:44 PM
Reply to this message Reply
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();
        /** 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();
        
    }
 
    public static void main (String[] args){
        Base base = new Base();
        /*  call methodA to display the output */
        base.methodA(33);
    }
}
 

Flat View: This topic has 1 reply on 1 page
Topic: java programming problem Previous Topic   Next Topic Topic: Java mail

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use