2013-11-15 156 views
-8

我收到错误您能否告诉我该文件中的错误在哪里?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”); 
    } 
} 
+5

你得到了什么错误? – Jim

+0

需要借出一些括号哈哈? – topcat3

+2

复制 - 粘贴问题?更改引号...将工作... – VinayVeluri

回答

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"); 
+1

谢谢Rj其解决:) –