
int g() { System.out.println("Inside method g"); int h() { System.out.println("Inside method h"); } }
Find the error in the following program segment and explain how to correct the error?

Firstly, int type of method always return value, but you didn't return anything. Secondly, you cannot define a method inside another method. Anyways, we have modified your code.
Here it is:
class Example2{
void g() {
System.out.println("Inside method g");
}
void h() {
System.out.println("Inside method h");
}
public static void main(String[]args){
Example2 ex=new Example2();
ex.g();
ex.h();
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.