20th Sep 2023, 4:41 PM
P A Arrchith Iyer
P A Arrchith Iyer - avatar
4 Answers
+ 6
It works. There is no error. What is it supposed to do?
20th Sep 2023, 5:23 PM
Lisa - avatar
+ 2
There's more to it, first of ... That code isn't a valid java code. If it's a valid java code, you have to create a file for it during runtime, open that file then can call "java -c filename" command with the system module and it will run the code from python. It's worth noting that the console would be different tho so you likely won't have an output here in sololearn. Java stdout is different from python's stdout
20th Sep 2023, 5:40 PM
Mirielle - avatar
+ 1
/*in java sad() can't return boolean and Object with method stop() at the same time */ public class SadStop_test { private static Sad sad = new Sad(); static Sad sad() { return sad; } static void beAwesome() { System.out.println("You are awesome !"); } public static void main(String args[]) { if (sad().isPresent() == true) { sad().stop(); beAwesome(); } } } class Sad { private boolean value = true; boolean isPresent() { return value; } void stop() { value = false; } }
23rd Sep 2023, 8:21 AM
21st Sep 2023, 3:17 PM
piotr skwarka
piotr skwarka - avatar