0
Can I make this code actually work🤔
4 Answers
+ 6
It works. There is no error.
What is it supposed to do?
+ 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
+ 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; }
}
0
👍