Question: Strings group 1 and group 2 are read from input. Each string represents a list of animal ( s ) surrounded by [

Strings group1 and group2 are read from input. Each string represents a list of animal(s) surrounded by "[" and "]".
Assign combinedAnimals with the concatenation of group1 and group2 in the order read.
Assign everythingList with a string that contains all the animal(s) in group1 and group2 in the order read, separated by "," and surrounded by "[" and "]".
Ex: If the input is:
[bison]
[penguin]
then the output is:
All groups in one line: [bison][penguin]
one group of all animals: [bison, penguin]
import java.util.Scanner;
public class JoinMultipleFields {
public static void main(String[] args){
Scanner scnr = new Scanner(
System.in);
String group1;
String group2;
String combinedAnimals;
String everythingList;
group1=5cnr* nextline ();
group2= scnr.nextline();
1
System.out.println("All groups in one line: "+ combinedAnimals);
System.out.println("One group of all animals: "+ everythingList);
}
 Strings group1 and group2 are read from input. Each string represents

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!