list in java
Java
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
public class Main {
public static void main(String[] args) {
List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
list.add("d");
list.add("e");
list.add("f");
//On met la liste dans le désordre
Collections.shuffle(list);
System.out.println(list);
//On la remet dans l'ordre
Collections.sort(list);
System.out.println(list);
Collections.rotate(list, -1);
System.out.println(list);
//On récupère une sous-liste
List<String> sub = list.subList(2, 5);
System.out.println(sub);
Collections.reverse(sub);
System.out.println(sub);
//On récupère un ListIterator
ListIterator<String> it = list.listIterator();
while(it.hasNext()){
String str = it.next();
if(str.equals("d"))
it.set("z");
}
while(it.hasPrevious())
System.out.print(it.previous());
}
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.ListIterator;
public class Main {
public static void main(String[] args) {
List<String> list = new ArrayList<String>();
list.add("a");
list.add("b");
list.add("c");
list.add("d");
list.add("e");
list.add("f");
//On met la liste dans le désordre
Collections.shuffle(list);
System.out.println(list);
//On la remet dans l'ordre
Collections.sort(list);
System.out.println(list);
Collections.rotate(list, -1);
System.out.println(list);
//On récupère une sous-liste
List<String> sub = list.subList(2, 5);
System.out.println(sub);
Collections.reverse(sub);
System.out.println(sub);
//On récupère un ListIterator
ListIterator<String> it = list.listIterator();
while(it.hasNext()){
String str = it.next();
if(str.equals("d"))
it.set("z");
}
while(it.hasPrevious())
System.out.print(it.previous());
}
}
Also in Java:
- Title
- java switch display panel
- Category
- Java
- Title
- how to take space separated input in java
- Category
- Java
- Title
- same method name with different arguments
- Category
- Java
- Title
- java double 2 decimal
- Category
- Java
- Title
- java http client eviction
- Category
- Java
- Title
- java random numbers in specific range
- Category
- Java
- Title
- how to exit a for loop in java
- Category
- Java
- Title
- random processing
- Category
- Java
- Title
- how take inputs in java with message
- Category
- Java
- Title
- how-to-use-volley-string-request-in-android
- Category
- Java
- Title
- java null pointer exception
- Category
- Java
- Title
- how to crate a list in java script
- Category
- Java
- Title
- how to get all the names of the files in a folder in java?
- Category
- Java
- Title
- binary to int java
- Category
- Java
- Title
- java find if element of list in present in another list
- Category
- Java
- Title
- raspberry stackexchange how to install the java jdk
- Category
- Java
- Title
- how to return the first character in an array from a method java
- Category
- Java
- Title
- sdkmanager JAVA_HOME invalid directory
- Category
- Java
- Title
- java arraylist
- Category
- Java
- Title
- javafx textarea size
- Category
- Java
- Title
- how to remove all items from alist in java
- Category
- Java
- Title
- raise number to power java
- Category
- Java
- Title
- vector length java
- Category
- Java
- Title
- recursive function for fibonacci series in java javascript
- Category
- Java
- Title
- Java app development
- Category
- Java
- Title
- primitive and non primitive data types in java
- Category
- Java
- Title
- how to print ascii value in java
- Category
- Java
- Title
- spring code in java
- Category
- Java
- Title
- isnumber java
- Category
- Java
- Title
- how to add a keylistener to a jframe
- Category
- Java
- Title
- countdown timer with seekbar
- Category
- Java
- Title
- java output array lists to file
- Category
- Java
- Title
- read from elasticsearch in spark
- Category
- Java
- Title
- java best way to concatenate strings
- Category
- Java
- Title
- java read lines from file
- Category
- Java
- Title
- how to create a method java
- Category
- Java
- Title
- how to check type of primitive value in java
- Category
- Java
- Title
- hashmap get value java
- Category
- Java
- Title
- java 8 group a collections by 2 property
- Category
- Java
- Title
- how to reverse a string in java
- Category
- Java
- Title
- java get environment variables
- Category
- Java
- Title
- Scanner library showing element not found exception
- Category
- Java
- Title
- how to make a list java
- Category
- Java
- Title
- system.out.println shortcut
- Category
- Java
- Title
- java iterate over a string
- Category
- Java
- Title
- if en une seul ligne java
- Category
- Java
- Title
- method resolve file in java
- Category
- Java
- Title
- write in file java
- Category
- Java
- Title
- tostring() java example
- Category
- Java
- Title
- java fx display simple rectangle
- Category
- Java
- Title
- java setter
- Category
- Java
- Title
- java string to boolean
- Category
- Java
- Title
- ujava saum of positive integers
- Category
- Java
- Title
- how to init an array with objects in java
- Category
- Java
- Title
- how to make an array in java
- Category
- Java
- Title
- spigot run command as console
- Category
- Java
- Title
- even or odd in java
- Category
- Java
- Title
- change fab image programatically
- Category
- Java
- Title
- convert localdatetime to localdate
- Category
- Java
- Title
- full shutdown windows 10 cmd
- Category
- Java
- Title
- how to find powers in java
- Category
- Java
- Title
- java rest client response json
- Category
- Java
- Title
- string to double java
- Category
- Java
- Title
- protect java
- Category
- Java
- Title
- how to iterate hashmap java
- Category
- Java
- Title
- make a commet in java
- Category
- Java
- Title
- java check if directory exists
- Category
- Java
- Title
- programmation android avoir acces à la liste des intents de partage
- Category
- Java
- Title
- get long from date java
- Category
- Java
- Title
- How to make a class in Java?
- Category
- Java
- Title
- taking string input in java
- Category
- Java
- Title
- big integer java
- Category
- Java
- Title
- biginteger in java
- Category
- Java
- Title
- jsonobject to java object
- Category
- Java
- Title
- java identifiers
- Category
- Java
- Title
- 3-way radix quicksort java
- Category
- Java
- Title
- how do i print text in java
- Category
- Java
- Title
- how to write a java for loop?
- Category
- Java
- Title
- connecting to h2 database from java
- Category
- Java
- Title
- android hide and show bottom navigation
- Category
- Java
- Title
- java stream find specific element
- Category
- Java
- Title
- java clear console
- Category
- Java
- Title
- how to convert a jsonobject to a dbobject
- Category
- Java
- Title
- java get keys from hashmap
- Category
- Java
- Title
- leap year checker java
- Category
- Java
- Title
- Category
- Java
- Title
- boolean java.lang.String.equals(java.lang.Object)' on a null object reference
- Category
- Java
- Title
- java method
- Category
- Java
- Title
- how to import a scanner in java
- Category
- Java
- Title
- take string from keyboard java
- Category
- Java
- Title
- java djikstra's algorithm
- Category
- Java
- Title
- deleting elements of an array in java
- Category
- Java
- Title
- java random boolean
- Category
- Java
- Title
- java size of stack
- Category
- Java
- Title
- get world by name bukkit
- Category
- Java
- Title
- generate a qr code in java
- Category
- Java
- Title
- get material of block bukkit
- Category
- Java
- Title
- java initialize string array
- Category
- Java
- Title
- compare list from db and list from request
- Category
- Java
- Title
- how to get orientation lock to portrait android stackoverflow
- Category
- Java