Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/loops/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Loops 如何将charCount集成到for循环中_Loops - Fatal编程技术网

Loops 如何将charCount集成到for循环中

Loops 如何将charCount集成到for循环中,loops,Loops,因此,我的任务是使用for循环计算给定字符串中的每个f,然后输出总和。这是我的尝试,但我不知道这个错误代码是什么意思。[1] 提前谢谢 String string = "Schiffe für den Fischfang."; int result4 = 0; for (int stelle = 1; stelle <= string.length(); stelle++) { if (strin

因此,我的任务是使用for循环计算给定字符串中的每个f,然后输出总和。这是我的尝试,但我不知道这个错误代码是什么意思。[1] 提前谢谢

        String string = "Schiffe für den Fischfang.";
        int result4 = 0;

        for (int stelle = 1; stelle <= string.length(); stelle++) {
            if (string.charAt(stelle) == 102) {
                result4++;
            }
        }
        System.out.println(result4); ```


  [1]: https://i.stack.imgur.com/0wSrs.png

请添加语言标记。