public class Codegym{
public static void main(String[]args){
double s = "Practice variables";
void doubleWrite(String s)
{
System.out.println(s);
System.out.println(s);
}
}
}
What is wrong in this implementation
Under discussion
Comments (4)
- Popular
- New
- Old
You must be signed in to leave a comment
Nouser
3 January 2021, 14:07
Java doesn't allow methods in methods. You need a class and inside that class you arange your methods like
0
Dinesh
3 January 2021, 14:30
Than why every thing need to be inside main()
0
Nouser
3 January 2021, 14:59
main is defined as the start point of your program. When the program is executed the JVM is looking for the main method and running the code here. That's all.
If you want to structure your program or want to avoid repetitions you write other methods and/ or classes. But per definition methods are't allowed to be in other methods.
0
Dinesh
4 January 2021, 04:10
Ok Thank you
0