Reputation: 11
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?
Upvotes: 1
Views: 279
Reputation: 10249
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)
Upvotes: 1
Reputation: 95988
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 :)
Upvotes: 1