Apache Kafka Tutorial
This Apache Kafka tutorial is for absolute beginners and discusses the architecture, core components and other advanced concepts.
Java 14 reached general availability on 17 March 2020. In this post, we will go through some features from the list of 16 new features added in Java programming language. We can find the JDK 14 binaries here. 1. JEP 305 – Pattern Matching for instanceof (Preview) In Java 14, …
Learn about traditional instanceof operator, enhancements introduced with pattern matching and the scope of pattern variables with examples.
Java records were introduced as a preview feature in Java 14 [JEP-359] and finalized in Java 16 [JEP-395]. A record, in Java, acts as a transparent carrier for immutable data. Conceptually, records can be thought of as tuples that are already available via 3rd party libraries. Though, records are built-in type …
In Java, a text block is a multi-line string literal. It means we do not need to get into the mess of explicit line terminators, string concatenations, and delimiters.
Java 14 (JEP 358) improves the usability of NullPointerException generated by the JVM by describing precisely which variable was null. Lets understand this in detail. 1. Better NullPointerException First, we need to pass -XX:+ShowCodeDetailsInExceptionMessages JVM flag to enable this feature while running the application. Make sure, you are passing it. …
Introduced in Java 13 as part of the enhancements in Project Amber, the ‘yield‘ keyword aims to simplify code, making switch expressions more concise and expressive. Let us learn about ‘yield‘ keyword, its purpose, syntax, and see some practical examples. 1. The ‘yield‘ Keyword The ‘yield’ keyword enhances the switch …
In Java, a switch statement generally allows the application to have multiple possible execution paths based on the value of a given expression in runtime. The evaluated expression is called the selector expression which must be of type char, byte, short, int, Character, Byte, Short, Integer, String, or an enum. …
The SoftMaxHeapSize option sets a soft limit on how large the Java heap should grow. When set, the GC will try not to grow the heap size beyond this limit.
Learn to create and use the Period class that was introduced as part of the new Date Time API in Java 8. The Period class represents the period of time in date-based values such as days, months, years, weeks, or years in the ISO-8601 calendar system such as “1 year …
Learn to use Java TemporalAdjusters that help with complex date-time calculations such as calculating recurring meeting dates, processing weekly reports, sending automated monthly report outs, etc. 1. Overview In the new Java Date API, the Temporal interface represents a date, time, or a combination of both. For example, LocalDate, LocalDateTime …
Learn to format a given date to a specified formatted string in Java. We will learn to use inbuilt patterns and custom patterns with DateTimeFormatter and SimpleDateFormat. 1. Formatting with DateTimeFormatter [Java 8] Since Java 8, We can use DateTimeFormatter for all types of date and time related formatting tasks. …
Learn to validate whether a given string contains a date value in Java using various date validation techniques available in Java 8.
Learn to get all the dates between the two given dates. We will see the solutions in Java 7, Java 8, and Java 9. 1. LocalDate.datesUntil() (since Java 9) LocalDate‘s datesUntil() method returns a sequential ordered stream of all dates between two given dates. The returned stream starts from startDate …
In Java, we can use the ChronoUnit and LocalDate.until() methods to calculate the number of days between two given dates. Other solutions exist, but these are the simplest and do not require importing an additional library. 1. Using ChronoUnit to Find the Number of Days between Two Dates Using ChronoUnit.DAYS.between() …
Learn to find all business days between two given dates in Java. The business days are considered all weekdays, excluding all holidays falling on weekdays. Once we have a List of business dates, we can use the list.size() API to get the total count of business days. The given examples …
Learn to add or subtract a given number of business days to new date times classes in Java such as LocalDate, LocalDateTime and ZonedDateTime. The given example takes the holidays list as well into consideration. Read More: Add or Subtract Days to/from Date 1. Adding Business Days It uses two …
Learn to determine which day of the week is a given date in Java. The weekdays are considered all 7 days from Sunday, Monday till Saturday. 1. DayOfWeek Enum DayOfWeek is an enum representing the seven days of the week – Monday, Tuesday, Wednesday, Thursday, Friday, Saturday and Sunday. 2. …
TemporalQuery is a standard way of querying the temporal objects (LocalDate, LocalDateTime etc) for making better business decisions. In Java 8, all major date-time classes implement Temporal and TemporalAccessor interfaces so TemporalQuery can be run against all those Java classes. 1. TemporalQuery interface In the new Java Date API, Temporal …
Java examples to get the next day or the previous day for any given day. The example uses legacy java.util.Date class as well as java.time.LocalDate class from Java 8. We can use this example code to calculate tomorrow’s and yesterday’s dates based on the date of today. 1. Using LocalDate …
Learn to find the last element of a stream in Java 8 or later. We will learn to use finite as well as infinite streams as well.
Few simple examples to find or count the duplicates in stream and remove the duplicates from stream in Java 8. We will use ArrayList to provide stream of elements including duplicates.
Learn to convert Iterable or Iterator to Stream. It may be desired at times when we want to utilize excellent support of lambda expressions and collectors in Java 8 Stream API.
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 examples (non-blocking and reactive) to perform HTTP GET, POST, PUT and DELETE requests and handle responses or errors.
Learn the differences between lists and tuples in Python. Tuples are great for creating Value Objects. Lists are for storing a collection of value objects.
In Python, tuples are compared lexicographically by comparing corresponding elements of two tuples. Learn to compare heterogeneous and unequal tuples.
In Pyhton, a tuple is similar to list except it is immutable and are written with optional round brackets. A Tuple is: immutable ordered heterogeneous indexed (starts with zero) written with round brackets (optional but recommneded) is faster during iteration, since it is immutable Tuples are useful for creating objects …
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.
In Python, lists are ordered, indexed (indices start at 0), mutable, heterogeneous (items need not be of the same type) and written CSV in square brackets.
Larn about Python string datatype and its functions. Learn how to format, align, find length and other such useful programs and exercises.
In Python, the int data type (integer) represents whole numbers that can be positive or negative and can have unlimited precision.
Python keywords are the reserved words and these keywords cannot be used for any other purpose than they have been designed for.
Learn to use Spring batch partitioning to use multiple threads to process a range of data sets in a spring boot application. 1. Parallel Processing and Step Partitioning 1.1. Parallel Processing Mostly batch processing problems can be solved using a single-threaded, but a few complex scenarios like single-threaded processing taking …
Learn to use the Spring batch Classifier with Composite Item Writer to classify the data and write to multiple destinations.
A data type defines the type of a variable. In this guide, we’ll explore some of the most commonly used built-in data types in Python with examples.
In Python tutorial, learn the basics of variables, naming conventions, and the difference between local and global variables with examples.
In Python (or any other programming language), comments are used to explain the source code. Comments describe the code, which helps in maintaining the application in the future for ourselves and others. In Python, comments come in two primary forms: single-line comments and multiple-line comments. Let us learn in detail. …
Java 8 IntPredicate is a functional interface whose functional method is boolean test(int a). It can be considered a function returning true or false value.
Java IntStream represents a stream of primitive int-valued elements supporting sequential and parallel aggregate operations.
Learn to use @RestClientTest annotation provided by Spring boot test module that focuses only on beans that use RestTemplateBuilder or RestTemplate.
Spring boot @DataJpaTest annotation focuses on JPA components and apply configuration only relevant to JPA tests. It helps in testing @Repository classes.
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.
Learn how to create and customize DataSource bean in Spring boot applications and configure connection pooling and multiple datasource beans.
Learn to implement AOP in Spring Boot applications and add different aop advices using AspectJ to support cross-cutting concerns, such as logging, profiling, caching, and transaction management.
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 …
Learn how to send email in spring boot applications with the help of JavaMailSender for sending simple emails as well as emails with attachments.
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.