ArrayList in Java: Complete Guide with Examples
ArrayList in Java: how to create, add, remove, iterate, convert to array, and common pitfalls. Complete guide with working code examples.
Tutorials, fixes for common errors, and interactive tools for every level. 300 articles available.
ArrayList in Java: how to create, add, remove, iterate, convert to array, and common pitfalls. Complete guide with working code examples.
Java OR operators explained: | (bitwise) vs || (logical short-circuit). Truth tables, short-circuit behavior, operator precedence and examples.
Get the length of a Java array with the .length property. Works for any type, multi-dimensional arrays, and comparison with String.length() and…
Get the length of a String in Java with length(). UTF-16 code units, emoji handling, surrogate pairs, null safety and comparison with…
Convert String to int in Java with Integer.parseInt() and Integer.valueOf(). Handle NumberFormatException, whitespace, radix, null, and safer parsing patterns.
Java constructors explained: default, no-arg, parameterized, copy, this() chaining, super(), private constructors and common pitfalls.
Convert int to String in Java with String.valueOf(), Integer.toString(), concatenation, formatted output and the difference between them.
How methods work in Java: declaration, parameters, return values, static vs instance, overloading, access modifiers and best practices.
Generate random numbers in Java: Math.random(), Random, ThreadLocalRandom and SecureRandom. Ranges, seeding, streams, thread-safety and gotchas.
Extract substrings in Java with String.substring(). Index rules, common pitfalls with surrogate pairs, StringIndexOutOfBoundsException, and modern alternatives.
compareTo() in Java: contract, Comparable interface, implementing ordering on your classes, sorting, pitfalls with equals and hashCode.
Split a String in Java with String.split(regex). Escape special characters, limit parameter, performance tips and alternatives like Splitter.
Java switch explained: classic statement, modern switch expression, arrow syntax, yield, pattern matching, and when to pick switch over if-else.
Read files in Java: Files.readString, Files.readAllLines, Files.lines stream, BufferedReader, encoding, large files and try-with-resources.
Java for loop explained: classic for(int i;...), enhanced for-each, infinite loops, break/continue, and when to use streams instead.
Java varargs (the ellipsis ...) let methods accept any number of arguments. Syntax, overloading rules, @SafeVarargs and common pitfalls explained.
Learn how to use 2D arrays with recursive methods in Java. Classic problems like flood fill, matrix traversal, and maze solving with…
Perform mutual TLS in Java using HttpClient: load a client certificate from a PKCS12 keystore, configure SSLContext, and send authenticated HTTPS requests.