小编JBa*_*esy的帖子

在switch语句中使用逻辑

我的问题与以下代码有关:

public static void main(String[] args) {

    // Find Prime Numbers from 0 to 100
    int i;
    for (i=2; i <= 100; i++) {
        int j = 2;
        boolean iPrime = true;

        //The following line gives incorrect results, but should execute faster
        //  while ((iPrime = true) && (j < (i / 2 + 1))) {
        //The following line gives correct results but performs un-necessary operations
        //by continuing to calculate after the number is found to be "not prime"
        while …
Run Code Online (Sandbox Code Playgroud)

java switch-statement

6
推荐指数
1
解决办法
260
查看次数

标签 统计

java ×1

switch-statement ×1