问答详情
源自:4-8 Java循环语句之 do...while

求解答关于do...while的问题

public static void main(String[] args) {

int sum=0;

int num=2;

do {sum=sum+num;

    num=num+2;

}while(num<=50);

}

System.out.println("0到50以内的偶数的总和为:"+sum);  //这一行提示有错误

}


错误信息是:

Multiple markers at this line

- Syntax error, insert ")" to complete MethodDeclaration

- Syntax error on token ".", @ expected after this token

- Syntax error, insert "SimpleName" to complete 

QualifiedName

- Syntax error, insert "Identifier (" to complete 

MethodHeaderName


提问者:郑龙鑫 2019-04-08 20:06

个回答

  • 11233
    2019-04-08 20:29:29
    已采纳

    https://img1.mukewang.com/5cab3ea10001aa7405410205.jpg

    你把输出语句写到main函数外面去了,删掉输出语句前面的括号