3 ms·
I'm also rather confused as to what "doesn't work in Java". The logical conjunction operator does short-circuit, it's merely restricted to the boolean type. Sin
by RodgerTheGreat 16y ago
I'm also rather confused as to what "doesn't work in Java". The logical conjunction operator does short-circuit, it's merely restricted to the boolean type. Since you aren't using the result, it doesn't matter:
static boolean print1000(int n) {
System.out.format("%d\n", n);
return n<1000 && print1000(n+1);
}
public static void main(String[] args) {
print1000(1);
}