Collection: Effectuer une recherche binaire dans une ‘ArrayList’

Author:

 list, list, arrayList, collection, collection, arrayList, java
{filelink=4861}

import java.util.ArrayList;
import java.util.Collections;

public class ArrayL_BinSearch
 {

  public static void main(String[] args)
  	{

    ArrayList array_L = new ArrayList();

    array_L.add("Java");
    array_L.add("Perl");
    array_L.add("PHP");
    array_L.add("CSharp");
    array_L.add("C++");

    // Le tri est obligatoire avant la recherche binaire
    Collections.sort(array_L);

    System.out.println("Contenu Trié : " + array_L);

    // Trouver python dans la collection
    int index = Collections.binarySearch(array_L, "Python");
    System.out.println("Index de python = " + index);  // "-N"
  }
}

A Voir sur le même Sujet:

  • arbre binaire avec arraylist en java
  • recherche +arraylist java
  • trie binaire java
  • recherche dans une collection
  • format binaire dans une arraylist
  • recherche dichotomique c# arraylist
  • arbre binaire de recherche
  • java+interface graphique+arrayliste+methode de recherche
  • recherche dans une arrayList java
  • effectuer une recherche hashmap java

Leave a Reply

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