Java简单程序

时间:2013-11-15 11:53:18

标签: java

我遇到错误你能告诉我这个文件中的错误在哪里吗?

public class IfSample {

    public static void main(String[] args) {
        int x,y;
        x=10;
        y=20;
        if(x<y) System.out.println(“x is less than y”);
        x=x*2;
        if(x==y) System.out.println(“x now equal to y”);
        x=x*2;
        if(x>y) System.out.println(“x is greater than y”);
        // this won’t display anything.
        if(x==y) System.out.println(“you won’t see this”);
    }
 }

1 个答案:

答案 0 :(得分:7)

您正在使用这些引号“”。这就是你得到错误的原因。使用字符串的标准双引号。

if (x < y)
    System.out.println("x is less than y"); // standard double quotes
x = x * 2;
if (x == y)
    System.out.println("x now equal to y");
x = x * 2;
if (x > y)
    System.out.println("x is greater than y");
// this won’t display anything.
if (x == y)
    System.out.println("you won’t see this");