Is it possible to write method inside method
Answers were Sorted based on User's Feedback
Answer / divya
no,it's not possible to write method inside a method.it
will gives an error illigal starts of expression
Is This Answer Correct ? | 17 Yes | 4 No |
Answer / janeesh
it is possible to write a method inside a method by using
method local inner classes.
Eg:
class Outer {
public void display() {
System.out.println("This is outerclass method.");
class Inner{
public void displayInner()
{
System.out.println("innerclass method");
}
}
Inner objC = new Inner();
objC.displayInner();
}
}
class MethodeInsideMethod {
public static void main(String[] args) {
Outer objC = new Outer();
objC.display();
}
}
Output:
This is outerclass method.
innerclass method
Is This Answer Correct ? | 11 Yes | 5 No |
How can we find the sum of two linked lists using stack in java?
What is native code?
Can interface be private in java?
what is session facade ?
Explain importance of throws keyword in java?
Is vector ordered in java?
How do you sing an Applet ?
Write the program numbers into words.For example 2345==two thousand three hundred fourty five
I declared main() method as private. But it still running and displaying the output. Please Answer it . Code Snippet as Below: import java.io.*; class over { private static void main(String[] args) { int high = Integer.MAX_VALUE; int overflow = high + 1; int low = Integer.MIN_VALUE; int underflow = low - 1; System.out.println(high + "\n" +overflow +"\n"+ low +"\n"+underflow); //System.out.println(overflow); //System.out.println(low); //System.out.println(underflow); } }
Is space a char?
Is null keyword in java?
What does replaceall do in java?