r/javahelp • u/kichiDsimp • Aug 31 '22
Unsolved Java Static
Why cannot we use System.out.println(), outside <main()> or any static function ?
0
Upvotes
r/javahelp • u/kichiDsimp • Aug 31 '22
Why cannot we use System.out.println(), outside <main()> or any static function ?
9
u/8igg7e5 Aug 31 '22
You can invoke
System.out.println()anywhere that you can use a non value returning statement, including in non-static methods, constructors appropriately typed lambda bodies or method references.Can you explain why you think this is not the case?