20th Sep 2023, 4:41 PM
P A Arrchith Iyer
P A Arrchith Iyer - avatar
4 Antworten
+ 6
It works. There is no error. What is it supposed to do?
20th Sep 2023, 5:23 PM
Lisa
Lisa - 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
zemiak
0
👍
21st Sep 2023, 3:17 PM
piotr skwarka
piotr skwarka - avatar