我的if-else语法有什么问题?

时间:2015-04-23 06:35:20

标签: java if-statement syntax

目前刚接触java,现在我正在做一个涉及if else语句的作业。有人可以为什么javac正在读我的其他东西晃来晃去?我的语法应该是正确的,除非我在这里遗漏了一些东西。enter image description here

5 个答案:

答案 0 :(得分:6)

你必须在if语句后删除你的分号。否则if后面的大括号不会被执行。

我希望这能解决你的问题。

if(Statement);
{
    //The Content would not be executed in realtion to the if-statemen
}

否则:

if(Statement)
{
    //The Content would be executed in realtion to the if-statemen
}

答案 1 :(得分:1)

删除if语句后面的分号(;)

答案 2 :(得分:0)

你的if后面有一个分号。删除它。

答案 3 :(得分:0)

您必须删除以databaseIndex开头的行尾的;

答案 4 :(得分:0)

改变:

if(...);
{
    ////
}

if(...)
{
    ////
}