Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(using Java) Hello, I need to change this code to use ArrayList insted of Array code below that I need to change import java.util.Arrays; import

(using Java) 
Hello, I need to change this code to use ArrayList insted of Array code below that I need to change 
import java.util.Arrays; import java.util.*; import java.lang.*; import java.io.*; public class ArrayOperations { public static void main(String[] args) { // TODO Auto-generated method stub System.out.println("********************"); show(new int[]{1,2,3}); show(new int[]{}); System.out.println("********************"); int c[] = reverse(new int[]{1,2,3}); System.out.println("Array Elements in reverse: "+Arrays.toString(c)); System.out.println("********************"); int max[] = max(new int[]{5,-10,7}, new int[]{10,-5,7,12,-14,0}); System.out.println("Max Array elements are: "+Arrays.toString(max)); System.out.println("********************"); boolean status = allSame(new int[]{5,5,5,5}); System.out.println(status); status = allSame(new int[]{5,5,4,5}); System.out.println(status); status = allSame(new int[]{5}); System.out.println(status); System.out.println("**********allDifferent check***********"); System.out.println(allDifferent (new int []{ 5,10,2,11} )); System.out.println(allDifferent (new int []{5,10,2,10} )); System.out.println("**********increasing check***********"); System.out.println(increasing (new int []{ 1,2,30}) ); System.out.println(increasing (new int []{1,2,-30}) ); System.out.println(increasing (new int []{5,5,6} )); System.out.println(increasing (new int []{}) ); System.out.println("**********nonzero check***********"); int d[] = nonzero (new int []{ 1,2,3}) ; System.out.println(Arrays.toString(d)); d = nonzero (new int []{1,0,-2,0,3}); System.out.println(Arrays.toString(d)); d = nonzero (new int []{0,0,0,0,0,0,0} ); System.out.println(Arrays.toString(d)); System.out.println("**********withoutRepeats check***********"); d = withoutRepeats (new int []{ 1,1,1,1,2,2,8,1,7,7,7} ); System.out.println(Arrays.toString(d)); System.out.println("**********Status***********"); double ans[] = stats(new double []{1.0,2.0,3.0,4.0, 5.0,6.0}); for(int i=0;i<5;i++) System.out.println(ans[i]); System.out.println("**********Concat***********"); System.out.println(concat(new String []{"She","sells","sea","shells"})); System.out.println("**********Find***********"); System.out.println(find ("blah", new String []{"Blah","blah","blah"})); String a[] = new String []{"Blah","blah","blah"}; // reverse(a); for(int i=0;i=0; i--, j++){ b[j] = a[i]; } return b; } public static int[] max(int[]a,int []b){ int length= 0; if(a.length > b.length) length = a.length; else if(b.length > a.length) length = b.length; else length = a.length; int c[] = new int[length]; for(int i=0; i a[i+1]) return false; } } return true; } public static int[] nonzero (int [] a){ //ask about this one int nonZeroCount = 0; for(int i=0; i                        

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 Administration The Complete Guide To Dba Practices And Procedures

Authors: Craig S. Mullins

2nd Edition

0321822943, 978-0321822949

More Books

Students also viewed these Databases questions

Question

8. Providing support during instruction.

Answered: 1 week ago