Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

Suppose there is an array list [10,5,20,19,15,24].Print them
in ascending & descending order in collection framework
concept ???

Answer Posted / abzy wabzy

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
public class MainClass {
public static void main(String[] a) {
List list = new ArrayList();
list.add("A");
list.add("C");
list.add("B");
Collections.sort(list);//for Ascending order
System.out.println(list);
Collections.sort(list, Collections.reverseOrder
());//for descending order
System.out.println(list);
}
}

Is This Answer Correct ?    5 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is the volatile modifier for? : Java thread

998


What advantage do java's layout managers provide over traditional windowing systems?

956


Does list allow duplicates in java?

930


how to know the total memory occupied by the objects in the ArrayList(Array list may contain duplicate objects)

2339


What is the symbol for space?

1000


What is application tier?

1120


What is a website container?

954


What are untrusted applets?

1144


Why do we use bufferedreader?

1008


What is the new line character?

1175


Can a class be declared as static?

1171


What is the static keyword?

1086


How many bits is size_t?

995


Why bytecode is called bytecode?

1205


Wha is the output from system.out.println(“hello”+null); ?

1143