Question: import java.util.Scanner; import java.util.Arrays; public class Main { / * * The 2 - dim return array array should have three rows. The first row

import java.util.Scanner;
import java.util.Arrays;
public class Main
{
/**
The 2-dim return array array should have three rows.
The first row should contain the zero integers from the input array.
The second row should contain the negative integers from the input array.
The third row should contain the positive integers from the input array.
The entries in each row should be in the same order that they were in in the input array,
Any one of the three rows could be an empty array (even all three of them).
Use an enhanced for-loop whenever possible.
*/
public static int[][] split(int[] array)
{
// This is just the "array of rows". You still need
// to create the three rows (after you know how big
// each row needs to be).
int[][] result = new int[3][];
return result;
}
// Do not modify this main method.
public static void main(String[] args)
{
final Scanner in = new Scanner(System.in);
final int size = in.nextInt();
final int[] array = new int[size];
for (int i =0; i < array.length; ++i)
{
array[i]= in.nextInt();
}
System.out.println(Arrays.toString(array));
System.out.println();
final int[][] splitArray = split(array);
System.out.println(Arrays.deepToString(splitArray));
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!