Explanation of Solution
Consider the given:
Declaring an array list named “primes” to store the first five prime numbers as follows:
//Declare an integer type array list
ArrayList<Integer> primes = new ArrayList<Integer>();
//Append the first prime value 2 to the array list
primes.add(2);
//Append the second prime value 3 to the array list
primes.add(3);
//Append the third prime value 5 to the array list
primes.add(5);
//Append the fourth prime value 7 to the array list
primes.add(7);
//Append the fifth prime value 11 to the array list
primes.add(11);
Loop to print elements in reverse order:
A loop to print the “primes” elements in reverse order is as follows:
/*loop to get each elements from primes in reverse order and print it on the screen */
for(int x = primes...

Want to see the full answer?
Check out a sample textbook solution
Chapter 6 Solutions
BIG JAVA: LATE OBJECTS
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





