我正在搜索代码行以使用名为 insertRow(int[] row) 的方法创建一个新数组。使用这种方法,用户可以插入 5 个数字组成一个数组。那么这个数组应该命名为row2。请帮忙。
public class App
{
public static void main(String[] args)
{
int[] row = new int[5];
int[] row1 = {2,7,1,9,4};
//int[] row2 = insertRow(row); this is wrong
}
public static void insertRow(int[] row)
{
for (int i = 0; i < row.length; i++)
{
int number;
do
number = Integer.parseInt(JOptionPane.showInputDialog("Insert the " + (i+1) + "th positif number"));
while (getal < 0);
row[i] = number;
}
}
}