Sort ArrayList in Java: Ascending and Descending Order
Learn to sort ArrayList in Java in ascending and descending order with List.sort(), Comparator.reverseOrder(), Collections.sort() and streams.
“Core Java” is Sun’s term, used to refer to Java SE, the standard edition and a set of related technologies, like the Java VM, CORBA, etc. This is mostly to differentiate from others like Java ME or Java EE. “Core Java” is Oracle’s definition and refers to subset of Java SE technologies.
The Core Java technologies and application programming interfaces (APIs) are the foundation of the Java Platform, Standard Edition (Java SE). They are used in all classes of Java programming, from desktop applications to Java EE applications.
Learn to sort ArrayList in Java in ascending and descending order with List.sort(), Comparator.reverseOrder(), Collections.sort() and streams.
To convert decimal to hexadecimal, divide by 16 repeatedly and read the remainders in reverse, so 269 becomes 10D. See a worked division table, a table of common conversion examples, and the Java one-liners for both directions.
Java record patterns with examples for instanceof, nested patterns, var, generics, sealed switch without default, null handling and MatchException.
Learn compact source files and instance main methods in Java 25 (JEP 512), formerly unnamed classes, with the IO class, implicit imports and rules.
Learn Java sequenced collections with examples of getFirst(), getLast(), reversed(), putFirst() and the exceptions and upgrade pitfalls to watch for.
Java 21 features with runnable examples for virtual threads, sequenced collections, record patterns and switch, plus each preview’s status in Java 25.
Fix This version of ChromeDriver only supports Chrome version with Selenium Manager, a clean PATH, a pinned Chrome for Testing build or WebDriverManager.
Learn how Java Map computeIfAbsent() works, with multimap and cache examples, null and exception rules, thread safety and the putIfAbsent() difference.
Java string templates were withdrawn in JDK 23 and do not exist in Java 25. See the old syntax, why it was dropped and the replacements that work today.
Java ConcurrentSkipListMap keeps keys sorted for many threads. Learn skip lists, floor and ceiling keys, live range views, polling and TreeMap differences.
Fix Java OutOfMemoryError by its message, from heap space and Metaspace to native threads, with JDK 25 output, container settings and heap dump analysis.
Learn how a JSON Web Token (JWT) works, create and validate one with jjwt 0.13 and nimbus-jose-jwt, and avoid the storage, key and expiry mistakes.
JPAstreamer guide with Spring Boot 4 and Hibernate 7. Set up the metamodel, filter, sort and page entities as Java streams, see the SQL and known issues.
Fix class file has wrong version 61.0, should be 52.0 by building with JDK 17+ in Maven, Gradle, IntelliJ and Eclipse. Includes a class version table.
The Java volatile keyword makes writes visible to other threads but does not make count++ atomic. See happens-before, stop flags and lazy singletons.
Are local variables thread safe in Java? Yes, each thread keeps its own stack copy. See when shared objects, lambdas and escaping references break it.
Convert primitive array to List in Java with boxed().toList(), loops, Guava Ints.asList() and ArrayUtils, and learn why Arrays.asList(int[]) fails.
Learn to handle exceptions in Java streams by wrapping checked exceptions, skipping bad elements with Optional or mapMulti, or collecting errors as values.
Learn Java ZoneId and ZoneOffset with examples. Create zones with ZoneId.of(), list all zone IDs, convert a ZoneId to a ZoneOffset at an instant, handle ZoneRulesException and use ZoneId.SHORT_IDS.
Generate a random number in a range in Java with nextInt(min, max + 1), legacy formulas, doubles, unique values, exclusions and secure codes.
Convert an Instant to ZonedDateTime in Java with atZone() or ofInstant(), choose the right zone, convert back with toInstant() and avoid date shifts.
Convert Instant to LocalDateTime in Java with LocalDateTime.ofInstant(instant, zone). Get LocalDate or LocalTime, pick the right zone, and convert back.
Convert String array to int array in Java with streams and Integer.parseInt(), get an Integer[] and skip or report invalid values safely.
Fix the JMH error Unable to find the resource /META-INF/BenchmarkList on JDK 23+ with Maven processor paths, proc full, Gradle and shaded JARs.
Mask a string except the last 4 characters in Java with repeat() or a regex lookahead, keeping dashes in card and phone numbers, null-safe.
Runnable vs Callable in Java explained with examples of return values, checked exceptions, Future, FutureTask, invokeAll and the Java 19 Future methods.
Learn the builder pattern for Java records with a nested builder, Lombok @Builder and RecordBuilder, plus defaults, validation and with methods on Java 25.
Learn what a daemon thread in Java is, how setDaemon() works, why the JVM does not wait for it, virtual threads, executors and when to use one.
Find the max value in a Java Map and its key with streams, Collections.max() or one loop, and handle min values, ties, empty maps and null values safely.
Assert two lists equal ignoring order with AssertJ, Hamcrest, Commons Collections or plain JUnit 6, and see which assertions count duplicates.
Learn FastExcel to write and read large Excel files in Java with streaming, flush(), typed cell getters, parallel sheets and a comparison with POI.
java.lang.UnsupportedOperationException means the code tried to change a collection that cannot be changed, such as one from Arrays.asList(), List.of() or Collections.unmodifiableMap(). Copy the data into an ArrayList or HashMap to fix it.
Java ArrayDeque tutorial with stack and queue examples, both-end methods, Java 21 reversed(), iteration, an undo history and ArrayDeque vs LinkedList.
Learn the JMH Java Microbenchmark Harness with the Maven archetype, the Java 23+ processor fix, @State, @Param, Blackhole, real results and pitfalls.
The full list of Java keywords as of Java 25, with 51 reserved and 17 contextual keywords grouped by category, literals, version history and rules.
Java IO tutorial for Java 25 covering Path and Files, byte and character streams, NIO channels, how IO works in the OS, and every file task by topic.
Java SynchronousQueue explained with put(), take(), offer() and poll() examples, a producer-consumer handoff, thread pool use and the alternatives.
Java Queue interface guide with the six methods, how to choose ArrayDeque, PriorityQueue or a BlockingQueue, iteration, BFS and thread-safe queues.
Java String methods grouped by task with Java 25 examples, from equals() and compareTo() to strip(), split() and replaceAll(), with pitfalls and FAQs.
Find a file in a directory and its subdirectories in Java with Files.find(), Files.walk() and walkFileTree(), with depth limits and globs.
Java stream groupingBy() examples that group a list by one or more fields and count, sum, average or sort each group with downstream collectors.
Convert a map to a list, array or set in Java using keySet(), values() and entrySet(), with streams, toArray(), ordering rules and lists of records.
Fix the IllegalStateException stream has already been operated upon or closed in Java. See why streams are single-use and three ways to reuse the data.
How to handle InterruptedException in Java correctly. Propagate it or restore the interrupt flag, avoid common mistakes, and cancel executor tasks.
Semaphore vs ReentrantLock in Java compared with a table and code for ownership, reentrancy, IllegalMonitorStateException, conditions and when to use each.
Learn to flatten a list of lists in Java with flatMap(), addAll() loops, mapMulti(), recursion for deep nesting, Guava and Eclipse Collections.
Convert List to Map in Java with Collectors.toMap() and groupingBy(), fix the duplicate key IllegalStateException with a merge function, keep order.
Learn to iterate over a stream with indices in Java using IntStream.range(), a record, a Java 24 gatherer, AtomicInteger, Guava and StreamEx.
Learn to remove or update list elements using streams in Java with filter() and map(), or in place with removeIf() and replaceAll(), using records.
Arrays.asList() vs new ArrayList() in Java explained with examples, covering fixed size, the shared array, List.of(), primitive arrays and conversions.
HowToDoInJava provides tutorials and how-to guides on Java and related technologies.
It also shares the best practices, algorithms & solutions and frequently asked interview questions.