This is not a Vaadin problem, but you are using Java in the wrong way. Classes can have fields in it directly, but all other code has to be put into methods, like the constructor. You are trying to add an item to the list outside a method.
This would work:
import java.util.ArrayList;
import java.util.List;
import com.vaadin.data.util.HierarchicalContainer;
import com.vaadin.terminal.Resource;
public final class ExampleUtil {
public ExampleUtil(){
List<String> ls=new ArrayList<String>();
ls.add("1");
}
}