如何描述此代码/将其分解? [英] How do I describe this code/break it down?
本文介绍了如何描述此代码/将其分解?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
请您分解以下代码吗?顺便说一下,这是在Intellij中使用jdk 1.8,使用'import java.util.scanner'代码行。
int sum = 0
for( int p = 0; p <10; p ++){
sum = sum + Array [p];
}
我尝试了什么:
我对编码非常陌生,需要帮助来解释以下代码。
Could you please break down the following code? By the way this is being done in Intellij with the jdk 1.8, with the 'import java.util.scanner' line of code.
int sum =0
for (int p = 0; p < 10; p++) {
sum = sum + Array [p];
}
What I have tried:
I'm very new to coding and need help explaining the following code.
推荐答案
你有一个名为Array
的数组,它包含整数值。
你循环通过数组中的前十个元素,使用p
作为索引,在第一次迭代中包含值0,在第二次迭代中包含1,依此类推,最后包含9迭代。在循环的每次迭代中,您将Array的当前元素的值添加到一个名为sum的总和
You have an array calledArray
which contains integer values.
You loop through the first ten elements in the array, usingp
as an index which contains the value 0 in the first iteration, 1 in the second, and so on up to 9 in the last iteration. In each iteration round the loop you add the value of the current element of Array to a total calledsum
参见 Java™教程 [ ^ ]。
这篇关于如何描述此代码/将其分解?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文