第7章课后作业5

public class Test{
public static void main(String[] args) throws Exception
{
int[] array = new int[]{1,3,-1,5,-2};
int[] array2 = new int[5];
for(int i = array.length - 1; i >= 0; i--)
array2[i] = (array[array.length - 1 - i] < 0 ? 0 : array[array.length - 1 - i] );

for(int i = 0; i < array2.length; i++)
System.out.print("" + array2[i] + ", ");
System.out.println();
}
};

你可能感兴趣的:(java)