This error occurs when there is code outside of a class declaration. The usual cause of this is when you're declaring a few objects at the start of the class, and mistakenly place them before the class has started.
String foo = new String();
public class MonkeyFarmer
{
becomes
public class MonkeyFarmer
{
String foo …