Background Given an ArrayList of Integers from 0 (inclusive) to 10 (exclusive) with step size 1. We use a while-loop and an Iterator<Integer> to check if this ArrayList hasNext() element, before we remove() the current element.
Problem The code below throws an IllegalStateException.
import java.util.ArrayList; import java.util.Iterator; import java.util.List; public class UnderstandArrayListIterator { public static void main(String[] args) { List<Integer> a = new ArrayList<>(); for (int i = 0; i < 10; i++) { a.
[Read More]
Passed Codingame Java Certification Test
A note to some forgotten methods
String regex replace using capture groups
Since Java SE 9, java.util.regex.Matcher
’s replaceAll()
method supports lambda expressions.
// import java.util.regex.*;
String varName = "random_string";
Pattern pattern = Pattern.compile("_([a-z])");
Matcher matcher = pattern.matcher(varName);
String result = matcher.replaceAll(m -> m.group(1).toUpperCase());
Source: Arvind Kumar Avinash’s answer on Stack Overflow
Check characters properties using Character
’s static methods
The Character
class provides some static predicates like
isAlphabetic(char c)
isDigit(char c)
isLowerCase(char c)
Diapo Sur HashMap
Java
Rendu compte des questions rencontrées dans mon apprentissage
Je me sers de ce fichier comme
la speech pour mes futurs entretiens le dépôt des doutes et leurs réponses que je recueilis dans mon apprentissage. Je ne cherche pas une réponse détaillée (qu’on trouve facilement dans un livre ou un manuel).
Générale C’est quoi Java ?
Java est un langage de programmation intermédiaire.
compilé : son compilateur produit un fichier qui n’est ni visible pour le développeur ni pour le système d’exploitation.
[Read More]