Answered step by step
Verified Expert Solution
Link Copied!

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 for-loop whenever possible.
*/
public static ArrayList> split(ArrayList 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 main(String[] args)
{
final Scanner in = new Scanner(System.in);
final ArrayList list = new ArrayList<>();
while ( in.hasNextInt())
{
list.add( in.nextInt());
}
System.out.println(list);
System.out.println();
final ArrayList> splitList = split(list);
System.out.println(splitList);
}
}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David Auer, Scott Vandenberg, Robert Yoder

10th Edition

ISBN: 0137916787, 978-0137916788

More Books

Students also viewed these Databases questions