EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Question:

Create an Arraylist by adding elements Apple,banana,mango

 

First element:Apple

Second element:banana

Third element:mango

 

sort the list

reverse the list

——————————-

import java.util.*;

 

class ASC

{

public static void main(String args[])

{

ArrayList<String> fruits=new ArrayList<String>();

 

fruits.add(“Apple”);

fruits.add(“Banana”);

fruits.add(“Mango”);

 

System.out.println(“First element:”+fruits.get(0));

System.out.println(“second element:”+fruits.get(1));

System.out.println(“Third element:”+fruits.get(2));

 

Collections.sort(fruits);

System.out.println(“Sorted list:”+fruits);

 

Collections.reverse(fruits);

System.out.println(“Reversed list:”+fruits);

}}

Java Array list by adding elements

Leave a Reply

Your email address will not be published. Required fields are marked *

EduLearn - Online Education Platform

Welcome to EduLearn!

Start learning today with our wide range of courses taught by industry experts. Gain new skills, advance your career, or explore new interests.

Browse Courses

Popular Courses

[Course Image]

Introduction to Programming

Learn the fundamentals of programming with Python in this beginner-friendly course.

12 Hours Beginner
[Course Image]

Data Science Essentials

Master the basics of data analysis, visualization, and machine learning.

20 Hours Intermediate
[Course Image]

Web Development Bootcamp

Build modern websites with HTML, CSS, JavaScript and popular frameworks.

30 Hours Beginner
[Course Image]

Digital Marketing Fundamentals

Learn SEO, social media marketing, email campaigns and analytics.

15 Hours Beginner
Educational Website Footer