【发布时间】:2013-07-20 05:10:23
【问题描述】:
我有以下代码:
/* Demonstrate the if.
Call this file IfDemo.java. */
package ifdemo;
public static void main(String args[}) {
int a,b,c;{
a=2;
b=3;
if (a<b) System.out.println("A is less than B");
//this won't display anything if (a==b) System.out.println("You won't see this")
System.out.println();
c=a-b; // C contains -1
System.out.println("C contains -1");
if (C >= 0) system.out.println("C is non-negative");
if (C < 0) system.out.println("C is negative");
System.out.println();
C=b-a; //C contains 1
System.out.println("C contains 1");
if (C >=0)System.out.println("C is non-negative");
if (C<0)System.out.println("C is negative");
}}
在线: public static void main(String args[} ) { 我得到三个错误: 1.令牌“void”的语法错误,@预期 2.令牌上的语法错误,应改为类头 3.标记的语法错误,错位的构造
希望大家能帮帮我。
提前致谢。
【问题讨论】:
-
注意Java中变量的大小写。是
if (c >= 0)等。同样把代码封装在一个类中 -
请在更新后点击edit并发布您修改后的代码。
标签: java error-handling