Object Identity String in Java with Objects.toIdentityString()
Learn what an object identity string is in Java, how Objects.toIdentityString() and System.identityHashCode() build it, and what its hash part means.
Learn what an object identity string is in Java, how Objects.toIdentityString() and System.identityHashCode() build it, and what its hash part means.
Base64 encode and decode a file in Java with examples for text and image files, data URIs, streaming large files with wrap(), MIME and decoding errors.
Learn to initialize HashMap in Java with Map.of, newHashMap and streams, and see how initial capacity and load factor decide when the map resizes.
A subclass replaces a parent method by overriding it. Learn the override keyword, noImplicitOverride, super calls and the rules the compiler checks.
For each interface, we must write a custom XmlAdapter class that handles the conversion between the value in Java Object and XML string.
In any programming language, naming conventions are a very important best practice to follow. Different parts of a program are written in specific cases so they can communicate easily their purpose in the source code. This short article lists some popular casings such as camel case, pascal case, snake case, …
Learn to solve the error “No default constructor found” when unmarshaling an XML to Java object using JAXB @XmlTransient and @XmlJavaTypeAdapter annotations.
orElse vs orElseGet in Java explained with examples. Learn why orElse always computes its default, when orElseGet saves work and how to avoid side effects.
An interface cannot be instantiated with new, but any object with the right shape matches it. Learn seven ways to create such objects and when to use each.
instanceof checks whether an object was created by a class and narrows its type. Learn how it works, where it fails, and how to check interfaces with in and type guards.
An interface describes a shape and disappears after compilation; a class describes a shape, holds code and exists at runtime. Compare them feature by feature.
TypeScript generics let one function, class or interface work with many types while the compiler checks every value. Examples cover constraints, keyof, defaults and const type parameters.
Extend a TypeScript interface with extends, combine several parents, merge declarations, and learn when an intersection type (&) is the better fit.
A TypeScript interface names the shape of an object. Learn to declare one, use optional and readonly properties, implement it in a class, and choose between an interface and a type alias.
Learn to write Spring Boot RESTs that help in downloading the Excel files (.xlsx) either stored in the server or generating and then sending it.
Learn to create generic and custom error pages for specific HTTP error codes in a Spring Boot application with configuration examples.
By leveraging Spring @Import and @ImportResource annotations, we can create more modular, maintainable, and flexible Spring Boot applications.
Spring Boot provides various ways to load property files such as default application.properties, spring profiles, custom property files, environment variables, and system properties.
Learn to create a Spring Boot project with Gradle from scratch, configure the build script, create a Spring Boot application class, and run the application.
Filter a Python list with filter() and a lambda. See its syntax and return value, and filter strings, objects, None values and items by another list.
Find the most frequent element in a Python list with Counter.most_common(), statistics.mode() and multimode(), pandas and NumPy, including ties.
Remove duplicates from a Python list while keeping order with dict.fromkeys(), a seen set, NumPy np.unique() and pandas, plus dedupe by key and timings.
Use the Python multidict library to map one key to several values. Add, getall, update, popall, CIMultiDict for headers, and defaultdict(list) compared.
Keep the last N items in Python with deque(maxlen=n) or slicing [-n:]. Covers lists, NumPy arrays, strings, the n=0 trap, file tails and moving averages.
Calculate the weeks between two dates in Java with ChronoUnit.WEEKS.between(), get leftover days, round up started weeks and count calendar weeks.
Get the day name from a date in Java with getDisplayName() and TextStyle, print it in any language, list all names and parse names back.
Split a date-time range into equal intervals in Java, cut fixed-length chunks, or split by days, weeks, months and years with half-open ranges and DST.
Java StopWatch examples with Guava Stopwatch, Commons Lang and Spring StopWatch, plus a small testable java.time version that records named laps.
Get the elapsed time since midnight in Java in seconds or milliseconds with LocalTime, in any time zone, correct on daylight saving days.
Learn to get the quarter from a date in Java with IsoFields, find quarter start and end dates, format Q3 labels and calculate fiscal quarters.
Convert month number to name in Java with Month.getDisplayName(), and parse full or short month names back to numbers in any locale.
Java date format with day period using pattern B in DateTimeFormatter (Java 16+). Print in the morning or at night, parse it and set custom ranges.
Learn how Math.divideExact() in Java detects the Integer.MIN_VALUE / -1 overflow, how it handles zero, and how it compares to floorDivExact().
Java Math.abs() vs Math.absExact() with examples. Why Math.abs(Integer.MIN_VALUE) is negative, when absExact() throws, and safe alternatives.
Java string concatenation performance on JDK 25 with JMH results, how + compiles since JEP 280, why += in loops is slow, and concat() vs StringBuilder.
Java text block formatting with variables using formatted(), String.format(), MessageFormat and named placeholders, plus what happened to string templates.
Write a Java multiline string with text blocks, control indentation, line breaks and trailing spaces, and see the String.join() options for Java 8 to 14.
Learn to build an online Python editor (using Flask, Docker, and Kubernetes) that allows users to write and run Python code directly from the browser.
Learn Python list comprehension syntax with examples. Place if and if-else correctly, flatten lists, pair two lists with zip() and build dicts and sets.
In this chatGPT tutorial, explore the entire life cycle of fine-tuning models from preparing training data, creating a fine-tuned model, and using it programmatically.
Learn the basics of ChatGPT, the ChatGPT API for Python, and how to use it for creating and performing NLP tasks with examples.
Spring 6 Programmatic Validator API allows to add fine-grained validation rules beyond the capabilities of annotations-based declarative approach.
Since Spring 6.1, JdbcClient provides a unified client API for JDBC query and update operations, offering a more fluent and simplified interaction model.
Big O notation categorizes the efficiency of a given algorithm and describes the upper bound of the growth rate of a function as the input grows.
Capture a Java thread dump with jcmd, jstack, kill -3 or JSON for virtual threads, read every line and find deadlocks, CPU hogs and stuck pools.
Soft delete rows with Hibernate’s @SoftDelete: see the UPDATE that replaces DELETE, choose the DELETED, ACTIVE or TIMESTAMP strategy, read and restore deleted rows with native SQL, and avoid unique constraint errors.
Learn to retry the failed requests with Spring WebClient’s retry() and retryWhen() operators including retry on specific exception cases.
By utilizing the –tests option, we can run unit tests using Gradle from entire test suites to specific test classes or methods.
Make JUnit @BeforeAll and @AfterAll non-static with @TestInstance(PER_CLASS). Project default, @MethodSource, @Nested, shared state and parallel tests.
In Spring, the default naming strategy utilizes the named of annotated classes or methods. Learn to customize it by explicit or custom naming with examples.
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.