私は50要素の配列を検索し、それらの要素を印刷するだけでなく、数値を見つける必要があるプロジェクトを持っています。私がそれを見つけたメッセージボックスを印刷したら!Java検索配列の番号
import java.util.*;
public class IT145_Homework_5_4 {
public static void main(String args[]) {
double alpha[] = new double[50];
boolean check = false;
// Initialize the first 25 elements of the array (int i=0; i<25; i++)
for (int i = 0; i < 25; i++) {
alpha[i] = i * i;
}
// Initialize the last 25 elements of the array (i=25; i<50; i++)
for (int i = 25; i < 50; i++) {
alpha[i] = 3 * i;
}
// Print the element of the array
System.out.println("The values are: ");
print(alpha);
}
// Print method to display the element of the array
private static void print(double m_array[]) {
for (int i = 1; i <= m_array.length; i++) {
System.out.print(m_array[i - 1] + " ");
if (i % 10 == 0)
System.out.print("\n");
}
}
}
変数を見つけたときにだけtrueにブールチェックを変更します。そしてそのループの中にメッセージボックスを印刷します。 –
私は疲れていて、この検索をどこに置くのかわからない...私はYouTubeで見て、検索方法を見つけたが、それはこの高度なものとしてそれを表示していない... –