1
public class Round15_Ex11 {
    partner in crime
    public static void main(String[] args) {
    ②
    }
}

In Eclipse, syso shortcut doesn't work in some part of code.
On the code I posted in the part numbered partner in crime, it doesn't work, and in the part numbered ②, it works.

And when I write any other class, in the part of class, It works.

What's the matter with shortcut? what am I supposed to fix with?

1

2 Answers 2

1

That's because you should write it inside a method, like area ②.

It won't compile if you write System.out.println("Yaay"); outside a method, like area ①, so that makes no sense that Eclipse will help you to do something that won't work, otherwise it'll be partner in crime :)

1

It doesn't work at (1) because you can only declare fields and methods in this part. This is why the shortcut won't work. eclipse knows that you cant do that here and will not suggest it. Have a look at Declaring Classes

You can only call methods like System.out.println() in methods (like (2)) or the static block.

(constructors are just "special" methods)

Not the answer you're looking for? Browse other questions tagged or ask your own question.