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