Question: Java: fill in the code. /** * YOUR NAME GOES HERE * 11/9/2016 */ import java.util.*; public class Chapter9b_FillInTheCode { public static void main(String[] args)

Java: fill in the code.

/** * YOUR NAME GOES HERE * 11/9/2016 */

import java.util.*;

public class Chapter9b_FillInTheCode { public static void main(String[] args) { ArrayList languages = new ArrayList<>(); languages.add("SQL"); languages.add("Java"); languages.add("HTML"); languages.add("PHP"); languages.add("Perl"); languages.add("Phyton"); languages.add("C");

// ------> exercise 9b1 // this code prints the number of elements in languages.

// your code goes here

System.out.println("Done exercise 9b1. ");

// ------> exercise 9b2 // this code prints all the elements in languages. // use for-each loop

// your code goes here

System.out.println("Done exercise 9b2. ");

// ------> exercise 9b3 // this code prints and counts all the elements in languages that start with the letter P. // use for-each loop

// your code goes here

System.out.println("Done exercise 9b3. ");

// ------> exercise 9b4 // this code retrieves the 9th element from languages if it is there (check the size) // and assigns it to the String variable webLanguage.

final int NOT_FOUND = -1; String webLanguage = "undefined";

// your code goes here

System.out.println("webLanguages is set to = \"" + webLanguage + "\""); System.out.println("Done exercise 9b4. ");

// ------> exercise 9b5 // this code replaces "HTML in languages (if it is there) with C++. // utilize ArrayList's indexOf method to find index of "HTML"

// your code goes here

System.out.println("Done exercise 9b5. ");

// ------> exercise 9b6 // this code finds the shortest name in languages: // get the first element and save it as the current shortest // use a regular for loop that starts at 1 to examine the rest of the collection

// your code goes here

System.out.println("Done exercise 9b6.");

// ------> exercise 9b7 // this code replaces element "PHP" with "Pascal" in languages // and utilizes ArrayList's toString method to print the content of languages

// your code goes here

System.out.println("Done exercise 9b7."); } }

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!