Spring Boot Retry Example
Learn to use Spring retry module for implementing retry-based remote API invocations that can handle runtime exceptions or network failures.
Learn to use Spring retry module for implementing retry-based remote API invocations that can handle runtime exceptions or network failures.
Learn to convert LinkedList to ArrayList in Java with example. We will also learn to convert arraylist to linkedlist in Java.
Learn to convert ArrayList to an array using toArray() method. The toArray() returns an array containing all of the elements in the list.
ArrayList contains() method is used to check if the specified element exists in the given arraylist or not. If element exist then method returns true.
Learn to use ArrayList ensureCapacity() method to increase the capacity of already initialized arraylist to a desired size. It improve performance of list.
Learn to update or replace an existing element in ArrayList with a new specified element or value, using set (int index, Object newItem) method. 1. Replacing an Existing Item To replace an existing item, we must find the item’s exact position (index) in the ArrayList. Once we have the index, …
Learn to check if an ArrayList is empty using isEmpty() and size() methods. Note isEmpty() method internally checks the size of the list.
Learn to format a specified string to a phone number pattern, which is ‘(123) 456-6789’. This conversion is generally required in applications where customer data has to be displayed, and phone number is part of this data. 1. Format String to ‘(###) ###-####‘ Pattern To format string to phone number …
Learn how to get first 4 characters of a String or simply any number of first characters of a string in Java.
Learn how to get last 4 characters of a String or simply any number of last characters of a string in Java.
Learn to clear arraylist or empty an arraylist in Java. Clearing a list means to remove all elements from the list. Difference between clear and removeAll.
Learn how to merge two arraylists into a combined single arraylist in Java. Also learn to join arraylists without duplicates in the combined list.
Learn to serialize and/or deserialize an ArrayList in Java with easy-to-follow examples. Note that the list items must also be Serializable.
Learn to swap two specified elements in ArrayList in Java. We will use Collections.swap() method to swap two elements within a specified arraylist at specified indices. 1. Collections.swap() API The Collections.swap() method swaps the elements at the specified positions in the specified list. The index arguments must be a valid …
Learn to synchronize an ArrayList using either Collections.synchronizedList() or CopyOnWriteArrayList class with examples.
Learn to compare two arraylists in Java with List Items. Learn to test whether two arraylists are equal and then find different list items.
Learn how to get the element from an ArrayList. We will be using ArrayList.get() method to get the object at the specified index of the arraylist.
Learn to get the index of the first occurrence of an element in an arraylist in Java using ArrayList.indexOf() method with a simple example.
Learn to get the index of last occurrence of an element in the arraylist in Java using Arraylist.lastIndexOf() method with a simple example.
Log4j2 RollingFileAppender is an OutputStreamAppender that writes log messages to files, following a configured triggering policy about when a rollover (backup) should occur.
Spring boot log4j2 properties configuration example. This enables log4j logging into any spring boot application and start logging into console or file.
Learn to get a sublist from an existing ArrayList using ArrayList.subList() and modify the original list using the sublist view.
The Java ArrayList class is part of the Collection framework and is an implementation of a resizable array data structure. It automatically grows and shrinks when elements are added or removed in the runtime, whenever required, This Java tutorial discussed the different ways to add multiple items to an ArrayList …
Learn to remove element from ArrayList. Remove element at specifed index, or element value. Remove all elements from arraylist for spcified value example.
Java programs to add single or multiple elements at the specified index of arraylist with ArrayList.add() and addAll() methods.
The Java iterate through ArrayList programs. Learn how to retrieve values from ArrayList in Java using for loop, while loop, iterator and stream api.
Java ArrayList can be initialized in one line using List.of(), and new ArrayList constructors. Learn to add elements one by one and in bulk.
Learn to intern a string, and how the string literals differ from string objects. Java String.intern() is a native method and performs fast.
Java String.contains() searches case-sensitive substring in a given string. It returns true if the substring is found, otherwise false.
Learn to enable and configure caching in a Spring boot application using @EnableCaching, @Cacheable, @CachePut and @CacheEvict annotations.
Java String toLowerCase() method transforms a String by converting all of its characters to lowercase, using the Locale rules if specified.
Java String toUpperCase() transforms a string by replacing all lowercase characters to uppercase while leaving any characters already in uppercase.
Java String split() returns an array after splitting the string using the delimiter or multiple delimiters such as common or whitespace.
The String.replaceAll(regex, replacement) in Java replaces all occurrences of a substring matching the specified regular expression with the replacement string. A similar method replace(substring, replacement) is used for matching the literal strings, while replaceAll() matches the regex. Note that in regular expressions, literal strings are also patterns, so replaceAll() will …
Java String.replaceFirst() replaces the first occurrence of a substring found that matches the given argument substring (or regex).
Java String replace() searches for a literal substring and replaces each occurrence with the replacement string beginning with index 0.
Java String.concat() concatenates the argument string to the end of the current string and returns the combined string.
Learn to find the substring of a string between the begin and end indices, and valid values for both indices with examples.
Java String.lastIndexOf() returns the last index of the specified character or substring in this string, if the substring is not found then it returns -1.
Learn to find the location of a character or substring in a given string and at what index position using the String.indexOf() with examples.
Java String hashCode() returns the hashcode for the String. The hash value is used in hashing-based collections like HashMap, HashTable etc.
Java String.endsWith() verifies if the given string ends with a specified substring or not. It does not accept NULL and regex patterns.
Learn to use the String.startsWith() and StringUtils class for checking a String prefix against a single value or multiple values.
Java String compareToIgnoreCase() example compares two strings lexicographically ignoring case. Learn how it differs from equalsIgnoreCase().
Java String compareTo() method example. Learn to compare two strings lexicographically. We can consider this string comparison dictionary based comparison.
Java String.equalsIgnoreCase() compares the current string with the specified string in a case-insensitive manner. Learn with examples.
Learn to compare the content of two String objects in a case-sensitive manner using the String.equals() API. For case-insensitive comparison, we can use the equalsIgnoreCase() method. Never use ‘==’ operator for checking the strings equality. It verifies the object references, not the content, which is undesirable in most cases. 1. String.equals() API …
Java String.charAt() returns the character at specified index argument in the string object or literal. The argument must be a valid index.
This article presents a simple Java program to find duplicate characters in a String. You can modify the code to find non-repeated characters in string.
Java hashCode() and equals() methods. Learn contract between hashCode and equals methods. How to correctly override both methods and best practices.
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.