-4

Here is my little example code:

String legend = "Øzil";
if (legend.equals("Øzil")) {
    System.out.println("You should have bought him Moyes");
}

Whenever I try to compile this code I get this error message: error: Not a Statement* String legend = Øzil"

Maroun
  • 94,125
  • 30
  • 188
  • 241
Sing Sandibar
  • 714
  • 4
  • 15
  • 26
  • 2
    Looks like you have a typo in your code, a missing parenthesis at the end of the `if` statement... – Luiggi Mendoza Nov 13 '13 at 14:31
  • @SteveP. Maybe it's a typo only in the question and not in his real code? He stated this in one of his comments. – Maroun Nov 13 '13 at 14:40
  • THERE'S NOTHING WRONG WITH CODE YOU POSTED! – Steve P. Nov 13 '13 at 14:42
  • Please provide more context around these statements. The code provided will compile just fine. OS/Java Version/Command being used to compile would help as well. – FGreg Nov 13 '13 at 14:43
  • @SteveP. Yes, the code may be fine, but why try to force OP to ask a question he clearly says is not relevant? – Zong Nov 13 '13 at 14:44
  • @ZongZhengLi I did not see that it was not relevant until he freaked out at me for no reason... – Steve P. Nov 13 '13 at 14:45
  • @SteveP. Yes, but he edited his question specifically to address the typo. It's best to just not touch syntax errors. – Zong Nov 13 '13 at 14:47
  • Could be related: http://stackoverflow.com/questions/1726174/how-to-compile-a-java-source-file-which-is-encoded-as-utf-8 – FGreg Nov 13 '13 at 14:57

4 Answers4

1

You have missed ) in the end of if statement

  if (legend.equals("Øzil") {
                          ^_____see here
Prabhakaran Ramaswamy
  • 25,706
  • 10
  • 57
  • 64
0

It's because of the funny character you are using, you should find its ASCII code and use it instead.

EDIT: ooops now I see I got it wrong :)

Lucas
  • 3,181
  • 4
  • 26
  • 45
0

try this one :

         String legend = "Øzil";

         if (legend.equals("Øzil")) {
                 System.out.println("You should have bought him Moyes");
          }
Vamshi
  • 510
  • 2
  • 10
  • 26
0

Add end bracket ) to the if condition:

From

if (legend.equals("Øzil") {

to

if (legend.equals("Øzil")) {
Mengjun
  • 3,159
  • 1
  • 15
  • 21