【发布时间】:2019-10-26 14:59:52
【问题描述】:
我正在尝试用随机位置的 10 个元素列表制作一个计数器,问题是在完成我的数组的完整浏览后,我必须在屏幕上打印有多少重复的数字。
为此,我在我的主空间中创建了方法,我声明了数组和“for循环”来浏览我的数组,问题是之后我必须在相同的方法中包含计数器吗? ...
public static int Vectores(int a[]) {
// Declared variable
a = new int[10];
int lf = a.length;
// Here we will tour the array and then complete the arrays with random numbers.
for (int i = 0; i < lf; i++) {
a[i] = (int) (Math.random() * 100);
System.out.println(" A:" + a[i] );
}
return a[i];
// Here will be an "if condition" + and for loop to the counter
int counter = 0;
for (int i = 0; i < 10; i++) {
}
} // END
【问题讨论】:
标签: java