Java Record Type: Syntax, Constructors and Examples
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 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.
Learn to set connection timeout, read timeout and write timeout periods for WebClient interface available in Spring 5 for making synchronous and asynchronous HTTP requests.
Spring WebClient is the non-blocking HTTP client of Spring WebFlux. Examples on Spring Boot 4 show GET with bodyToMono and bodyToFlux, POST with a JSON body, onStatus error handling, timeouts, block() vs subscribe(), logging, and tests with MockWebServer.
Compare Python lists and tuples by mutability, hashability, memory in Python 3.14 and use cases, with the single-element tuple trap and named tuples.
Python compares tuples element by element from the left. Learn the rules, mixed-type errors, all() with zip(), sorting by tuple keys and version checks.
Learn the Python tuple with examples. Create one-element tuples, index and slice, sort, unpack with *rest, use named tuples, count(), index() and keys.
Learn to build automatic pagination links (next, prev) in spring boot hateaos application using PagedModel and PagedResourcesAssembler classes.
Learn to customize the name generated for embedded collection model using @Relation tag in spring boot hateoas application.
Learn to build hateoas links for REST resources using RepresentationModel and RepresentationModelAssemblerSupport in a Spring boot application example.
Learn Python lists with examples. Create, index and slice, add and remove items, join lists, sort and copy, and every list method with its return value.
Learn Python strings with examples. Slicing, f-strings, immutability and join(), plus all 47 string methods with return values, capitalize() to zfill().
Learn the Python integer (int) type. Hex and binary literals, floor division of negatives, int() and str() conversion, the 4300-digit limit and bit tools.
See the list of all 35 Python keywords with an example for each, the soft keywords match, case, type and _, and how to check names with the keyword module.
Partitioning in Spring Batch splits the data of one step into separate ranges, and a worker step processes each range in its own thread. We use it when a single thread takes too long to read and process a large number of records, for example millions of rows in a …
Learn to use the Spring batch Classifier with Composite Item Writer to classify the data and write to multiple destinations.
Learn the Python built-in data types with examples. str, int, float, list, tuple, range, dict, set, bool, bytes and None, plus type() and mutability.
Learn Python variables with examples. Naming rules, multiple assignment, references, local and global scope, nonlocal, UnboundLocalError and type hints.
Write Python comments with #, multi-line comment blocks, docstrings vs triple-quoted strings, editor shortcuts and special comments such as # noqa.
Java IntStream guide with range(), rangeClosed(), iterate() and chars(), loop replacements, map and filter, sum() overflow, conversions and a real example.
Use @RestClientTest and MockRestServiceServer to verify an outgoing Spring Boot 4 RestClient request, JSON mapping, and 404 handling with runnable tests.
Test Spring Data JPA repositories with @DataJpaTest on Spring Boot 4.1.2. Run H2 query tests, verify rollback behavior, and see how to keep a configured datasource.
Spring boot @Repository annotation is a specialization of the @Component to indicate a data repository used for storage, retrieval, and search behavior.
Spring boot makes application development easier but we may face some tough interview questions when it comes to test your knowledge on how it all works. Be prepare for the next job interview with given Spring boot interview questions and answers.
Configure a DataSource in Spring Boot 4 with spring.datasource.url, username and password, and Spring Boot creates a HikariCP pool. Tested examples for pool tuning, DataSourceBuilder, a second DataSource, schema.sql and data.sql, and tests with H2 and Testcontainers.
Build a Spring Boot 4 AOP aspect that measures order service methods. Run tests showing advice on successful and failed calls, and why self invocation bypasses the Spring proxy.
Learn about the most widely used spring annotations. In this tutorial, we will briefly cover the important annotations which are provided by spring core to define beans and create complex application context configurations. 1. Annotations in Spring Framework Similar to other places, annotations help by providing metadata and instructions to …
Send an order confirmation with a CSV attachment and inline image using Spring Boot 4.1.2. Test the received MIME parts with a local GreenMail SMTP server.
Learn to add internationalization (i18n) support to Spring Boot REST APIs through the auto-configuration of MessageSource and translation files.
Learn to enable HTTP response gzip compression in a Spring Boot application. By default, the gzip compression is disabled in Spring Boot.
Produce JSON from @RestController methods and consume it with @RequestBody in Spring Boot 4 with Jackson 3. Covers the 400, 415 and 406 errors, Jackson 3 defaults, spring.jackson properties, a JsonMapperBuilderCustomizer, annotations, Gson and tests.
Learn to write unit tests and integration tests in spring boot applications along with spring context, test annotations and mock support.
Use Spring Boot 4 @MockitoBean in MVC slice and full-context controller tests. Compare it with a plain Mockito mock and see when a missing bean is created or an existing one replaced.
Maven keeps using a corrupt JAR or a cached failed download until we remove it. Learn which error means which problem, when mvn -U helps, and how to clean the local repository on any OS.
Test a Spring WebFlux controller with @WebFluxTest, WebTestClient and @MockitoBean on Spring Boot 4.1.2. Verify JSON, 404 responses and the difference from a live-server test.
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.