Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Simple JAVA Program Please Answer the bold italicized parts. public class Q01 { public static void main(String[] args) { ArrayList list = new ArrayList ()

Simple JAVA Program

Please Answer the bold italicized parts.

public class Q01

{

public static void main(String[] args)

{

ArrayList list = new ArrayList() ;

//-----------Start below here. To do: approximate lines of code = 2

// 1. a loop to put in list a sequence of BankAccount objects

//where the balances are 2.05, 4.05, 6.05, ..., 100.05

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

System.out.println(list) ;

/* Expect

[2.05, 4.05, 6.05, 8.05, 10.05, 12.05, 14.05, 16.05, 18.05, 20.05, 22.05, 24.05, 26.05, 28.05, 30.05, 32.05, 34.05, 36.05, 38.05, 40.05, 42.05, 44.05, 46.05, 48.05, 50.05, 52.05, 54.05, 56.05, 58.05, 60.05, 62.05, 64.05, 66.05, 68.05, 70.05, 72.05, 74.05, 76.05, 78.05, 80.05, 82.05, 84.05, 86.05, 88.05, 90.05, 92.05, 94.05, 96.05, 98.05, 100.05]

*/

}

}

======================================

public class StringSorter

{

public static void main(String[] args)

{

String[] array = {"blue", "red", "yellow", "cyan", "orange",

"purple", "mauve", "brown"} ;

ArrayList list = new ArrayList() ;

//-----------Start below here. To do: approximate lines of code = 1

// 1. write a for loop to copy the elements of the array to the list

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

System.out.println("--------------original list:") ;

System.out.println(list) ;

Collections.sort(list) ;

System.out.println("--------------sorted list:") ;

System.out.println(list) ;

System.out.println("--------------original array:") ;

System.out.println(Arrays.toString(array)) ;

//-----------Start below here. To do: approximate lines of code = 2

// 2. sort the array using Arrays.sort

System.out.println("--------------sorted array:") ; //

//3. print the sorted array

//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.

}

}

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

Professional IPhone And IPad Database Application Programming

Authors: Patrick Alessi

1st Edition

0470636173, 978-0470636176

More Books

Students also viewed these Databases questions

Question

My opinions/suggestions are valued.

Answered: 1 week ago