Question
5.ArrayList,15points Create a static method calledflip2that takes anArrayListofStringsas a parameter and thenflipseach successivepair ofvalues in the list.For example, suppose that a variable calledliststores the following
5.ArrayList,15points
Create a static method calledflip2that takes anArrayListofStringsas a parameter and thenflipseach successivepair ofvalues in the list.For example, suppose that a variable calledliststores the following sequence of values:
["aa","bb","cc","DDD","happy","snow"]
and we make the following call:
flip(list);
Afterwards the list should store the following sequence of values:
["bb","aa","DDD","cc","snow","happy"]
If the list has extra values that are not part of apair, those values are unchanged.For example, if the list had instead stored:
["aa","bb","cc","DDD","happy","snow","hometown"]
The result would have been:
["bb","aa","DDD","cc","snow","happy","hometown"]
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