Answered step by step
Verified Expert Solution
Question
1 Approved Answer
import java.util.Scanner; import java.util.ArrayList; import java.util.Arrays; public class Main { / * * The returned ArrayList > should have three sub lists. The first sub
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
public class Main
The returned ArrayList should have three sub lists.
The first sub list should contain the zero integers from the input list.
The second sub list should contain the negative integers from the input list.
The third sub list should contain the positive integers from the input list.
The entries in each sub list should be in the same order that they were in in the input list,
Any one of the three sub lists could be an empty list even all three of them
Use an enhanced forloop whenever possible.
public static ArrayList splitArrayList list
This is the outer ArrayList. You still need to create
the three sub lists that act like rows and add
each sub list to this list. Then add the appropriate
integers to each sub list.
ArrayList result new ArrayList;
return result;
Do not modify this main method.
public static void mainString args
final Scanner in new ScannerSystemin;
final ArrayList list new ArrayList;
while inhasNextInt
list.add innextInt;
System.out.printlnlist;
System.out.println;
final ArrayList splitList splitlist;
System.out.printlnsplitList;
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started