Pattern Matching for instanceof in Java (Java 16 to 25)
Pattern matching for instanceof in Java with type patterns, flow scoping, null and generics rules, equals() examples, record patterns and Java 25 updates.
“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.
Pattern matching for instanceof in Java with type patterns, flow scoping, null and generics rules, equals() examples, record patterns and Java 25 updates.
Learn the Java record with examples of compact constructors, methods, generics, immutability, serialization and when a record should not replace a class.
Learn the Java yield keyword with switch expression examples, arrow and colon cases, yield vs return vs break, exhaustiveness and contextual keyword rules.
Java -XX:SoftMaxHeapSize sets a soft heap limit below -Xmx. Which GCs honour it, the jcmd byte-value trap, MXBean code and a container example.
Learn the Java Period class to create, parse, read and add years, months and days, with normalized(), month-end rules and Period vs Duration examples.
Java TemporalAdjusters examples for month ends, next weekdays and the second Tuesday, plus custom adjusters for working days, paydays and anniversaries.
Learn to format a date to string in Java with DateTimeFormatter, ISO constants, custom patterns and Locale, plus Instant, legacy Date and pattern mistakes.
Check if a date is valid in Java with LocalDate and a strict DateTimeFormatter, then add rules such as not in the past. Covers leap years and regex limits.
List all dates between two dates in Java with LocalDate.datesUntil(). Learn how to include the end date, step by weeks or months, skip weekends, and do the same in Java 8.
Calculate the days between two dates in Java with ChronoUnit.DAYS.between() and until(), count inclusive days, handle date-times, DST and the Period trap.
Count the business days between two dates in Java with datesUntil(), exclude weekends and holidays, pick an inclusive end date or use a loop-free formula.
Add business days in Java by skipping weekends and holidays with LocalDate, subtract them with the same method, and support Fri-Sat weekends.
Learn the Java DayOfWeek enum with getValue() vs ordinal(), day names in every style, parsing text, EnumSet, week start per locale and adjusters.
Learn Java TemporalQuery with the built-in TemporalQueries, method references and custom queries for business hours and fiscal quarters, with null rules.
Get the next and previous date in Java with plusDays(1) and minusDays(1), plus time zones, DST, the next Monday and the next working day with LocalDate.
Learn how to get the last element of a stream in Java with reduce(), Guava findLast() and Java 21 getLast(), including empty and infinite streams.
Find duplicates in a Java stream with groupingBy() and counting(), list repeated elements, count each one, and remove duplicates from lists or by a field.
Convert Iterable to Stream in Java, and an Iterator too, with StreamSupport and Spliterators, a reusable helper, Guava and single-use iterators.
Java IntStream guide with range(), rangeClosed(), iterate() and chars(), loop replacements, map and filter, sum() overflow, conversions and a real example.
Generate a Java UUID with randomUUID(), build name-based v3 and v5 UUIDs, create time-ordered v7 keys on Java 25 and 26, and parse and store them safely.
Pair in Java with Map.entry(), AbstractMap.SimpleEntry, records, javafx.util.Pair, Commons Lang Pair and Vavr Tuple2, plus a guide to choose one.
Learn to parse a date-time string to UTC in Java with Instant, OffsetDateTime and ZonedDateTime. Covers strings with Z, an offset, GMT or no zone at all. Also covers RFC 1123 dates, old SimpleDateFormat code and common DateTimeParseException causes.
ResolverStyle.STRICT rejects dates like February 30 that SMART and LENIENT adjust. See all three styles side by side, the uuuu vs yyyy trap and fixes.
Regex match any character in Java with the dot, .* and .+, plus DOTALL and [\s\S] for line breaks, lazy .*?, literal dots and character classes.
Regex end of line and start of line in Java with $ and ^, MULTILINE mode, the trailing line break trap, \A and \z, and Windows line breaks with \R.
Java DelayQueue explained with a Delayed record, take(), poll() and peek() rules, a producer-consumer order timeout example and the alternatives.
Shut down a Java ExecutorService with shutdown(), awaitTermination() and shutdownNow(), or with try-with-resources and close() on Java 19+. Covers queued tasks, RejectedExecutionException, virtual threads, JVM exit and shutdown hooks.
Learn to cancel a task in ExecutorService with Future.cancel(), stop running tasks with interrupts, cancel after a timeout and clean up with purge().
Java ScheduledExecutorService examples for delayed and periodic tasks, scheduleAtFixedRate vs scheduleWithFixedDelay, exceptions, cancel and daily jobs.
Learn how ExecutorService invokeAll() runs a batch of Callable tasks, with timeouts, failed tasks, Future.state() and invokeAny() for the first result.
A RejectedExecutionHandler decides what happens to a task that a ThreadPoolExecutor cannot accept. Compare the four built-in policies with real output and write custom handlers.
Learn ExecutorService in Java with Java 25 examples for submit(), invokeAll(), Future results, close() with try-with-resources and virtual threads.
Compact number formatting in Java with CompactNumberFormat. Format 1000 as 1K or 1 thousand, control decimals and rounding, parse values and use locales.
Java String isBlank() checks if a string is empty or only whitespace. See isBlank() vs isEmpty() and trim(), null-safe checks, Unicode cases and FAQs.
Repeat a string N times in Java with String.repeat(), StringBuilder.repeat(), String.join() with nCopies, Java 8 loops and StringUtils, with edge cases.
Collectors teeing() runs two collectors in one stream pass and merges the results. Examples for min and max, filter and count, records and nesting.
Compare LocalDateTime in Java with isBefore(), isAfter(), isEqual() and compareTo(), ignore seconds with truncatedTo() and handle values from other zones.
Compare LocalDate values in Java with isBefore(), isAfter(), isEqual(), equals() and compareTo(), with the values compareTo() returns and a booking check.
AtomicInteger lets many threads update one int without a lock. Covers every method with results, compare-and-swap, AtomicInteger vs synchronized vs volatile, and LongAdder for high contention.
Show time in Java 12-hour format with AM/PM using the pattern letters h and a, fix pm vs PM locale output, and convert between 12 and 24 hours.
Java examples to format a LocalDate to String with toString(), DateTimeFormatter.ofPattern(), the ISO constants and localized FormatStyle with Locale, and to parse the String back.
Check leap year in Java with Year.isLeap() and LocalDate.isLeapYear(), learn the 4, 100 and 400 rule, and handle February 29 in date math.
Compare ZonedDateTime in Java by instant with isEqual(), see why equals() and compareTo() differ across zones, and handle DST gaps and overlaps.
Format ZonedDateTime to String in Java with ISO constants, zone letters z, VV and XXX, localized styles, and the same moment shown in other time zones.
Convert LocalDate to ZonedDateTime in Java with atStartOfDay(zone) or atTime().atZone(), and back with toLocalDate(), including DST days and zone pitfalls.
Convert LocalDate to LocalDateTime in Java with atStartOfDay() and atTime(), and back with toLocalDate(), plus zone-aware day starts and day ranges.
Parse String to ZonedDateTime in Java with ISO text, VV and XXX patterns, ambiguous names like PST or IST, and strings that have no time zone.
Convert a string to LocalDateTime with LocalDateTime.parse() and DateTimeFormatter. Learn the ISO format, pattern letters, AM/PM and Locale, strings with a zone, date-only strings, strict parsing and common error messages.
Convert String to LocalDate in Java with LocalDate.parse(), custom patterns, month names in any locale and safe DateTimeParseException handling.
Java ZonedDateTime examples on Java 25. Create, parse and format zoned date-times, handle DST gaps and overlaps, and convert a time between zones.
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.