{

Learn free java tutorials


10 Interview Questions answers for Log4j in java

May 1, 2023 ·  4 min read

This post talks about Frequently asked questions in Java interviews with answers. It includes detailed answers to real-time questions for Developers and backend developers. What is Log4j and why it is used? Log4j is a logging framework written in java language, It is provided by the apache foundation. In the applications, if you want to log the same information, like any event, triggered, or any Database update happens, We need to log the specific information or error for the usefulness of the application....


2 ways to create Connection Pool in java with examples

May 1, 2023 ·  4 min read

What is a Connection Pool in java Usually, applications are hosted on the application server and talk to the database using a database connection. The database connection is a simple HTTP socket connection from the java code to the database machine. Whenever the application receives a request, it establishes a simple socket connection to the database; once the request is completed, the connection is timed out/closed; in this way, the system is connected for each request....


2 Ways to solve java.lang.ArrayIndexOutOfBoundsException errors in java

May 1, 2023 ·  2 min read

In this blog post, learn How to Fix/handle java.lang.ArrayIndexOutOfBoundsException errors in java What is java.lang.ArrayIndexOutOfBoundsException error in java? This exception is one of the common exceptions in java. Java developers used to get this exception in the projects when data was retrieved from the database as well as dealing with arrays and array lists. ArrayIndexOutOfBoundsException is a class in java. lang package which extends IndexOutOfBoundsException, extended by RuntimeException. IndexOutOfBoundsException is a runtime exception which occurs during java execution in a java virtual machine....


3 Ways to Convert java.sql.date to/from Localdate in java: examples

May 1, 2023 ·  1 min read

java.sql.Date is a date class used to store date, time, and timezone information. LocalDate is stores Date only without time and timezone information This short tutorial talks about how to convert SQL date to /from localdate in java with examples How to convert LocalDate to java.sql.date in java This example parse LocalDate to java.sql.date in java with example. LocalDate has the valueOf method which converts to SQL date. import java.sql.Date; import java....


3 ways to Count Number of days between two dates in java| example

May 1, 2023 ·  2 min read

In this tutorials, We are going to learn different examples about Difference between two dates and return number days months and weeks Given Util Date is older than 90 days How to count the Number of days between two Localdate in java java.time.temporal.ChronoUnit is an Enumeration class introduced in java8. It is used to measure the time in Years, Months, Weeks, Days, Hours, Minutes. The below example finds the number of days, weeks, months, between two dates....


5 ways to convert Array to List in java

May 1, 2023 ·  3 min read

In this post, We are going to learn multiple ways to convert the array to ArrayList in java. The array is static and fixed in the size of the data structure. ArrayList is a dynamic data structure. Convert Array to ArrayList For example, Let’s create an array of strings as seen below. String[] words = new String[] { "one","two","three" }; (or) String words[] = { "one","two","three" }; Create a string array and initialized with a list of strings....


5 ways to sort an array of custom objects by property in java with examples

May 1, 2023 ·  4 min read

It is a short tutorial on multiple ways to sort an array of objects in java. Let’s define an Employee.javaclass. public class Employee { private Integer id; private String name; private Integer salary; public Employee(Integer id, String name,Integer salary) { this.id = id; this.name = name; this.salary=salary; } public Integer getId() { return id; } public void setId(Integer id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this....


Apache Derby Database Tutorials With examples

May 1, 2023 ·  3 min read

In this blog post, learn Apache Derby Database tutorials with examples. Apache Derby Database tutorials It is an Opensource relational Database developed completely in Java language. It supports the ANSI-SQL standard. It uses as Embedded in java applications or can act as an independent database server. Features It is relatively small in size around 4MB. It supports JDBC and ANSI-SQL Standards It is simple to install and Setup Embedded Derby Database This database runs inside the application in the same JVM....


Best ArrayList Class examples in java| java array list tutorial

May 1, 2023 ·  5 min read

This tutorial explains ArrayList basics in java and features and the top best examples. Contents ArrayList in java Important points to remember for ArrayList Real-time ArrayList Usage examples How to create an ArrayList How to add Objects to ArrayList? How to iterate the elements in the ArrayList? How to find the size of ArrayList? How to check if the object/element is found in ArrayList How to Convert ArrayList to the array?...


Best 15 examples of a String class| string class in java

May 1, 2023 ·  4 min read

Contents What is a String class in java? why are String objects immutable? How to create a string object in java? How to find the length of the string? How to append the strings in java? How to compare two strings of data and references in java? How to Split a string into substrings in Java format String with an example in java:-** How to Convert String to Integer in java How to Reverse a String example in java Conclusion What is a String class in java?...


Design patterns advantages and disadvantages in java

May 1, 2023 ·  1 min read

In Software development, reusable code to solve the frequent problems that occurred in the designation of any system In OOPS programming, we have several design patterns the following are the Popular design patterns. There are different categories and types of design patterns in object-oriented programming. Creation patterns This type of pattern is used to describe object creation in the best possible ways in different contexts. Singleton is the example Structural design patterns Behavioural design pattern Benefits of design patterns:- Improves the performance of the system....


Different Ways to Convert InputStream to String java with examples

May 1, 2023 ·  3 min read

In this post, We are going to learn how to convert InputStream to String in java with examples. In Java, if we want to read and write files, We have to use Input and output streams. These I/O Streams are files or devices or any other source. for example, InputStream is used to read the data from the file system OutputStream is used to write the data to the file system...


Different ways to print java object tutorials with examples

May 1, 2023 ·  6 min read

In this blog post, We are going to learn the following things How to print java object content for example. Java object print using to String method Print object content as a String Java array objects print example Java object collection print example ToStringBuilder class - Print all fields of a java object as a string Convert Java object as json string A Java class is a set of properties and methods and it is a blueprint for an object....


final keyword in java with examples

May 1, 2023 ·  3 min read

final keywords are applied to variables, method, and class. and the meaning is once the final is applied, its value or state cannot be changed. what are the final variables in java? if we apply the final keyword to fields or member variables, the variables are tread as constants, which means once the variable is created, and assigned with value, The value can not be changed. final int value=20; // Gives compile time error for the below line of code value=40; I the above example,...


Find out 32 bit or 64-bit java JDK version in Java

May 1, 2023 ·  3 min read

I have encountered one of the issues with java installation that is not compatible with my 32-bit machine. This blog post is helpful for to check the JVM version to install the latest java version install. Check 32 bit or 64 bit for Java installation 32 bit is 4 bytes of size, whereas 64 bit is 8 bytes of size. That means 64-bit takes more memory than 32 machines. Most of the time, if your code compiles with the 32-bit JDK version, then you need to execute these class files in a 32-bit machine/64-bit machine only....


Front Controller Design pattern tutorials with examples in Java

May 1, 2023 ·  3 min read

Front Controller is one of the most important design patterns used in web applications. It is a single palace controller to handle all your request to an application. Front controllers are mostly used in MVC applications and the following are implemented in frameworks. Legacy Java web apps Struts Spring boot and MVC Angular, React, and Vuejs framework Microsoft .net and Sharepoint Why Front controller pattern required? Let’s see the reason for the front controller and what issues are solved?...


Gitignore file generate in Eclipse|Intellij|Netbeans

May 1, 2023 ·  2 min read

In this blog post, We are going to learn how to git ignore files in IDE - Eclipse, IntelliJ, and Netbeans In my previous post, We are going to learn gitignore file tutorials with examples gitignore file The gitignore file contains patterns of files and folders that prevent committing to the git repository when the code is committed and pushed to a remote repository. This file is specific to IDE and Operating systems and languages....


Grails with java: Learn Basics of Grails Domain Constraints

May 1, 2023 ·  2 min read

Grails Constraints grails are a framework developed in a groovy framework which internally uses java to build the applications very quickly. I got a chance to work on the grails application. so I want to blog about the grail constraints. As you know in any web programming language, we need to do the form level validations. which we can do either at client level validation or server level validation client level validations mean, the entered data cannot be sent to the server and do the validation at the browser, To do this, we have a lot of scripting languages like JavaScript or vb scripts....


Hibernate criteria query | restriction projections Order by examples

May 1, 2023 ·  3 min read

Hibernate Criteria API criteria are used to select the specific type of data from the database. Let us take the use case, where the website has search capability provided, you have to search the website with different conditions, To handle this using hibernate, we can compose different parameters to the Criteria object and make custom SQL queries to the database to retrieve the data. Hibernate criteria API is an alternative to Hibernate query language or HQL and generates complex queries using different criteria....


How do convert string to Integer or Integer to String in java?

May 1, 2023 ·  4 min read

Contents How to Convert String to Integer in Java How to convert String to Integer using java Constructor How to convert String to Integer using Integer.parseInt() method How to convert String to Integer using valueOf() method How to convert String to Integer using NumberUtils from apache commons library How to Convert Integer to String in Java? How to Convert Integer to String using valueOf() method in String How to Convert Integer to String using toString method How to Convert Integer to String using Append empty String Conclusion As a developer, in day-to-day programming, we have encountered many situations to convert from String to Integer or vice versa....


How to add changelog to database changes in java | Liquibase spring boot tutorial

May 1, 2023 ·  3 min read

We have many source code repositories like git and svn for managing and tracking code changes to the application developed using programming languages. Have you ever thought of how do you manage and track and apply database schema changes? This post explains a tool called liquibase, an open-source library to track and make database changes in a single place. Liquibase maintains and tracks changes in scripts or changelog. This changelog is configured in XML, JSON, YAML, and SQL....


How to avoid ConcurrentModificationException for map or List

May 1, 2023 ·  4 min read

The ConcurrentModificationException exception is thrown due to one thread trying to read the object and the other thread trying to modify the object. This happens to all java collection API classes - List, HashMap, HashTable, LinkedHashMap In the below example Create an ArrayList of Strings. Create an Iterator using Iterate using the iterator() method Check for the next element exists or not using the hasNext() method if the next element exists, Print the element During iteration, Trying to remove an element based on a Conditional check This will throw an error Exception in thread "main" java....


How to Change Java version in Intelli

May 1, 2023 ·  2 min read

In this blog post, You are going to learn to change the java version for Intelli Boot Run time to start the application. Intelli java project maven project. How to change the java version to the project in Intelli IDE? Here is a sequence of steps Go to the File menu Select Project Structure, An popup window is displayed seen below Select SDKs under platform Settings Change the JDK version or add new versions and change to it...


How to Convert Float to String or String to Float in java with examples

May 1, 2023 ·  2 min read

Float and String are data types of objects used to store different values. In Applications, the UI form can have an input text value that accepts the floating value, To deal with form submission and do manipulation of these float values. We do convert for String to float or float to String in Java. This tutorial talks about various ways to do this conversion. float values example: float f = (float) 4....


How to convert String to Double or Double to String in java | Double example

May 1, 2023 ·  2 min read

Double String example The string is a sequence of characters enclosed in double-quotes. Double is the numeric data type of double-precision floating values that hold double primitive types. Both have different values for different purposes. Sometimes, In our applications, It is required to convert a string to double or vice-versa in java. It is a basic common requirement for knowing developers. Double holds 64 bits numbers, double value has d or D added to its value....


How to convert String to Long or Long to String in java with examples

May 1, 2023 ·  3 min read

Long, String objects conversion in java Long is an object which holds larger values. It is a wrapper class in java for primitive type long. if you initialize long values, you need to add l to its value. The string is a class to represent a group of characters enclosed in double-quotes. if the string contains non-numeric characters, converting these non-numeric values to long or any numeric data type results in NumberFormatException....


How to count the number of instances of a class in java?

May 1, 2023 ·  2 min read

These are short tutorials on how to count the number of instances/objects of a class in java. An object of a class can be created using a new keyword in java. an object is an instance of a class. A class can have multiple objects. How do you count the number of objects/instances of a class in java? static is the global scope that can be created and accessed by all objects of a class....


How to create a timer in java?|Timers java example?

May 1, 2023 ·  4 min read

Java timer: In this tutorial, learn how to create a timer and timer task in java for example. what are timers in java? We have seen many scheduler programs in Linux which are based on cron jobs. Java has also a mechanism to provide the limited scheduling mechanism with the Timer and TimerTask Task. if you want a full pledge scheduler, you can use the quartz scheduler. Before timers classes are introduced, we have to write our own custom code for scheduler tasks using our own calculation logic using threads....


How to create and initialize ArrayList in java with one line?

May 1, 2023 ·  2 min read

This is a short tutorial on how to create an array list and initialize it with objects in a single line. Normally, You can create and add data into an ArrayList with the below lines of code ArrayList<String> names = new ArrayList<String>(); places.add("Name1"); places.add("Name2"); places.add("Name3"); How could we refactor the above code with a single line? Yes, we can do it in multiple ways, This will be helpful to have static fixed data that can be used in unit testing or anywhere....


How to delete duplicate objects from an ArrayList in java?

May 1, 2023 ·  2 min read

It is a short tutorial that talks about How to Store unique objects to avoid duplicates in java List? In real-time scenarios, you encountered cases having duplicate objects in a list. There are no java Collections List implementations to solve this. In Collections, List allows duplicate values and maintain the insertion order, whereas Set does not allow duplicates, doesn’t maintain order. To achieve this, We can do this in several ways....


How to display line numbers in eclipse| line number color

May 1, 2023 ·  2 min read

This post covers solving line numbers in the Eclipse code editor for the below things. display line numbers in eclipse editor by default Eclipse line number disappears after setting the “Show line settings” option Changing the default line number color in the eclipse code editor How to show or hide line numbers in Eclipse Editor To show or hide line numbers in Eclipse, Please follow the below steps. First, Go to Windows -> Preferences It will open the preference window Go to General -> Editors -> TextEditors check “show line numbers”....


How to enable http2 in spring boot application| HTTP Compression example

May 1, 2023 ·  3 min read

The following things need to be set up http2 in the spring boot application. As you know latest browsers support http2 with SSL/TLS configuration Required Spring boot maven or Gradle How to configure and enable http2 in spring boot application Here is step by step to configure in spring boot in the 2.0 and 1.5 versions. Create and configure HTTP SSL certificate To set up http2, First, you need to configure the SSL configuration....


How to enable http2 in tomcat 9 and 10 | Compression configuration to http2

May 1, 2023 ·  3 min read

It is a short tutorial on how to change the HTTP version from 1 to 2 in Tomcat. Http2 is good in performance compared with the HTTP 1.0 version. HTTPS2 solves performance problems while loading resources over HTTP with binary format and multiplexing. Http2 feature binary format multiplexing Supports server push mechanism HPACK header compression algorithm to improve performance Need HTTPS configuration as a prerequisite HTTPS handshake is not supported in WebSockets...


How to find the tomcat version installed| check the java version used in tomcat

May 1, 2023 ·  2 min read

Sometimes, We need to find the tomcat version installed on the machine. version. sh or version.bat in the bin folder of the tomcat folder gives tomcat and java versions of the machine. version. sh is for Linux and Unix OS version.bat is for windows In this tutorial, Different ways we can check the installed Tomcat version. Check the tomcat version in windows? First, go to the installed folder on tomcat home...


How to fix java.lang.UnsupportedClassVersionError: Unsupported major.minor version

May 1, 2023 ·  3 min read

UnsupportedClassVersionError is a runtime error thrown when Java code is compiled and run with incompatible and unsupported java versions. UnsupportedClassVersionError extends ClassFormatError which is a sub class of LinkageError. This is a runtime error thrown by JVM as it tried to run a java class file that has major and minor versions that are not supported. error stack trace contains a message like an Unsupported major. minor version x.x. x.x is a number corresponding to the version of your installed java version....


How to get the first and last element of ArrayList in java

May 1, 2023 ·  2 min read

Most of the time, we encountered the situation to read the first element of ArrayList using the get(0) method. In some instances, you want to get the last element of an Array List. This post talks about multiple ways to read the last element of an ArrayList or LinkedList. For example, Let’s create an array list for this example. ArrayList<String> list=new ArrayList<>(); list.add("one"); list.add("two"); list.add("three"); list.add("four"); Java List provides size() method to return many elements....


How to get variable name in java class example| getDeclaredFields reflection

May 1, 2023 ·  2 min read

In this example, How to get variable names of a class using reflection. Reflection package API in java provides to analyze and update behavior of java classes at runtime. class or interface in java contains variables declared with different types and modifiers - public, final, private, default, protected, and static. print public variable names of a java class using reflection API getFields() method of an java.lang.Class gives list of all public aviable variable names of an interface or class in java....


How to inject enum object of java in spring framework?

May 1, 2023 ·  2 min read

Spring framework is a popular open-source framework developing applications in java. Enum is a java enumeration keyword introduced in java 5 features. In the Spring configuration file, we will inject different custom classes as well as predefined classes like Integer, String. How to Inject Enum in Spring IOC container? But injecting enum class in the spring container is different as if we do not correctly inject, we will end off with exceptions like “org....


How to Internationalization java applications

May 1, 2023 ·  2 min read

Usually, applications are developed in English, but when we want our applications to target users or customers of different countries, Sun provides the Internationalization concept in java. Internalization or I18n is a set of Java classes or interfaces provided by java to support the global application in java. It means Java applications work with multiple languages and multiple countries. What are items to do in Internationalization DateFormat Time Zone NumberFormat Message Format current symbol when we target the above things, the application is named as internationalized applications...


How to replace eclipse tab with spaces in java

May 1, 2023 ·  2 min read

Eclipse code editor, By default text, is intended with tab characters. We can change this tab behavior in eclipse in multiple ways. Some programmers use other text editors like Intelli IDEA and VSCode. Each IDE has tab settings configured by default. You will get indentation style issues when you are importing non-eclipse projects. This post solves how to replace tabs with spaces in the code editor of eclipse. As tabs are applied to the code editor....


How to solve IllegalArgumentException in java with examples

May 1, 2023 ·  2 min read

Fix for IllegalArgumentException in java:- IllegalArgumentException is one of the frequent exceptions that occurred in a java programming language. This exception extends RunTimeException class. These are also called UncheckedExceptions and need not be handled in java code for these exceptions occur at runtime. Exceptions in java are used to indicate that there is an error in your code. IllegalArgumentException is a good way of handling the code. This exception occurs when a caller calls the method with incorrect argument types for the methods....


How to sort Numbers ArrayList in java with examples

May 1, 2023 ·  2 min read

It is a short tutorial about Different ways to sort the list of numbers in java. Let us say We have a set of numbers say 100,200,4,5,79,26. We can use either Array or List implementation(ArrayList or LinkedList in java.util package used to sort numbers Java8 How to sort the list of numbers with the stream.sorted() It is an example for sort ArrayList of numbers natural order ascending order descending order Here is the sequence of steps...


Issues with OutOfMemoryError: PermGen space in tomcat and solution

May 1, 2023 ·  3 min read

Recently when I have deployed a web application in tomcat 6.0.32 in a windows Development environment, I got the following PermGen Space errors. so I would like to write the post on this with the root cause and exceptions Caused by: java.lang.OutOfMemoryError: PermGen space at java.lang.ClassLoader.defineClass1(Native Method) at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631) at java.lang.ClassLoader.defineClass(ClassLoader.java:615) at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141) What causing OutOfMemoryError? This issue either occurs in the startup of your application or runtime whenever the application is running....


java - Epoch or Unix timestamp and convert to from Date with examples

May 1, 2023 ·  3 min read

What is the Current Epoch time? Epoch time is many seconds that already passed from 1 January 1970 UTC. For a day, the total number of seconds is 24* 60*60 seconds. Epoch time returns the long number between the current time and 1 January 1970. It is also called Epoch Unix time. Every programming language provides API for handling Unix time. Java also provides a Date API for manipulation of Epoch Time....


Java 10 Local variables Type Inference tutorials with examples

May 1, 2023 ·  6 min read

In this tutorial, Learn the Java 10 feature Local variables Type with examples. InferenceJDK Enhancement Proposal(JEP-286) is a new feature in Java 10 Contents What is Local variable type inference in java10? How compiler interprets var types? Basic Type inference example -var keyword Type safety with var example in java10 For Loop local variable type inference example in java10 For each local variable type inference example var variable inside the method and return value in java10 local variable for storing Ternary Operator result Declare a local variable for Streams local variable type Inference Compilation Errors Java 10 local variables interference Advantages Disadvantages Conclusion What is Local variable type inference in java10?...


Java 11 String methods| lines strip isBlank examples| new features

May 1, 2023 ·  2 min read

In this blog post, learn the six new methods added to the String class in Java 11. JDK 11 - Strings methods Java 11 Version added a few more methods to the string class. This method helps the developer to simplify the coding styles and improve performance. lines() example Returns the Stream of strings separated with a line break from multi-line strings Syntax: Stream<String> lines() Stream lines = string.lines(); This method can be rewritten in the older version using the stream below....


Java Code Names with versions List

May 1, 2023 ·  1 min read

As everyone works on java programming language, But you don’t know java history when it was released what are code names and their versions. Most people are confused with the code names and versions. Since 1.8 version onwards, Code Names are discontinued from java release Java codenames and versions list Here are java code names and their versions list. JDK or J2SE Code Name |J2SE 1.8 |No codenames from this version| |Java SE 7 |Dolphin| |Java SE 1....


java Collections overview

May 1, 2023 ·  1 min read

java.util.Collection Collections are data structures are used to represent a group of elements stored under a single name. Different operations like searching, sorting, insert, delete and filter operations will be performed on collection classes. Java provides several classes and interfaces to deal with collections. Java collections are defined in java. util package java.util.Collection and java.util.map interfaces are root interfaces in which all collection classes are extending either one of the interfaces....


java Deque object with examples

May 1, 2023 ·  5 min read

Deque Object in java Deque is abbreviated as a double-ended queue, It is like a normal queue, which can store the collection of objects. It is one of the collections classes introduced in Java 6. Why deque is different from other collection classes? the answer is, in the deque, we can insert and delete the objects from both starts, end of the collection. whereas normal collection inserts/deletes are happening at last only....


java enumeration tutorial: Best 10 examples of enum constants in java

May 1, 2023 ·  5 min read

This tutorial explains Enumeration in java with examples. Contents What is Enum in java How to define an enum class? How to define an enum in another class? How to create an enum object? How to define an enum constructor? How to compare Enum objects in Java? How to iterate enum constants How to convert an enum to an integer? How to convert an integer to an enum constant? How to convert String to an enum object?...


Java Multi catch block exception handling example tutorial

May 1, 2023 ·  2 min read

Java 7 Exception Handling Java7 language has introduced features like Usage of Strings in Switch case and improved the exception handling. It introduced a multi-catch block. A single catch block is not sufficient to handle multiple exceptions before Java 7. We can achieve this using multiple catch block, where each catch block is used to catch a single exception. Let us see the example of Java7 Multi-catch exception example...


Java NumberFormat tutorials: 3 Examples of NumberFormat in java

May 1, 2023 ·  5 min read

When developing applications for different countries, the data display should be customized to each country, even if the data storage is always the same. For java programmers, formatting the same data to a specific country is a tedious task. java introduced the Globalization and localization concept. Many formatting classes, including NumberFormat, are included in the java.text package as part of this. What is internalization and localization in java? Internalization is a programming approach for coding software applications in such a way that they work in different languages and countries....


Java String in switch case examples

May 1, 2023 ·  3 min read

String in switch case Java7 version has been introduced using a string in the switch case. Before the Java7 version, Switch case allows only Integer, byte, short, char variables, and enumeration values only. Support of String is not allowed. This feature is handy for developers to use strings directly in switch cases and simplify the developers in readability. Let us see the following code. public class SwitchWithStringsDemo { public static void main(String[] args) { int days = 1; String s="one"; String numberValue; switch (s) { case 1: numberValue = "ONE"; break; case 2: numberValue = "TWO"; break; case 3: numberValue = "THREE"; break; default: numberValue = "Invalid number"; break; } } } What will happen if we compile the above program in eclipse/net beans using Java 1....


Java Unique Number Generator - UUID or GUID with examples

May 1, 2023 ·  4 min read

In this blog post, We are going to learn java Unique Number Generator- UUID or GUID with examples. You can also check my previous articles on UUI. javascript UUID Generator example VueJS UUID Generator example Angular UUID Generator example React UUID generator Example Java Unique Number Generator - UUID The universally unique identifier is a unique string to represent information in software applications. There are two types of unique identifiers....


java- java.lang.StringBuilder class, methods examples with tutorials

May 1, 2023 ·  3 min read

In this blog post, We are going to learn the StringBuilder class and its method tutorials with examples. java.lang.StringBuilder class StringBuilder class is used to manipulate the string of characters in a mutable way. It is replaced in place of String and StringBuffer. Some of the features of the StringBuilder class in java. This class is defined in java.lang package. Syntax: public final class StringBuilder extends AbstractStringBuilder implements java.io.Serializable, Comparable<StringBuilder>, CharSequence Import notes of StringBuilder and differences with other String classes...


javac compiler tutorials with examples in java| Javac command

May 1, 2023 ·  6 min read

In this blog post, We are going to learn the java compiler command with tutorials and example usage. Java compiler - Javac tool Javac is a java compiler tool developed by Sun framework and now it is owned by Oracle. Java compiler used to read the java program and compile java program and convert into machine-readable bytecode. Javac tool is shipped as part of JDK software installation and location is in the bin folder of JDK installed folder....


jcmd command-line utility tool to debug and diagnostic java application

May 1, 2023 ·  3 min read

In this blog post, learn JCMD command-line utility with examples. jcmd command-line tool JCMD is a command-line utility tool to diagnose the java process. It uses Java applications to debug the following use cases. When a Java application is crashed To know the Application Heap Memory and Garbage collection troubleshoot and diagnose JVM applications This tool is available as part of Java JDK installation. It sends a diagnostic signal to retrieve JVM debugging information process id and class....


Jdbc Basic Example to connect to the database in java

May 1, 2023 ·  2 min read

Following steps for writing a sample java program to connect to the database and get the result. JDBC API is provided by sun framework which contains different interfaces and classes to connect to databases. The below diagram depicts the steps to connect to any database. Here is an example for connection to the database in java import java.sql.Connection; import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.Statement; public class ConnDemo { public static void main(String args[]) throws Exception { // establish connection to database this includes loading driver // and fetching data....


JDBC Interview Questions and answers latest 2022

May 1, 2023 ·  3 min read

what are the different frequent JDBC classes or interfaces used in java code? Connection,DriverManager,ResultSet,Statement,PreparedStatement,CallableStatement. What are different driver types supported in JDBC? Driver Type Description JDBC-ODBC bridge It is a bridge between client code and database machine Type2 driver Client-side installation required to connect to database Type3 It uses middleware network to convert JDBC calls to native calls Pure JavaDriver The driver code is written in java and converts java code into native database-specific operations 2....


Learn Basics of Arrays tutorials with examples in java

May 1, 2023 ·  3 min read

Java Array Introduction The array is used to hold a collection of elements under a single name. Here a collection of elements are of the same type are passed. If you have a list of values to store it, without arrays, you have to declare elements, if there are 200 values, You have to declare 200 declarations. String str1="one" String str3="two" String str3="three" Instead of a multiple values declaration, Arrays store the collection of elements under a single variable name....


Learn CopyOnWriteArrayList tutorials with examples in java

May 1, 2023 ·  3 min read

CopyOnWriteArrayList is a class in java.util.Concurrent package. It introduces in Java 5 as part of java concurrency API changes. It uses in multi-threaded safe applications. It is a concurrent version of ArrayList. Why CopyOnWriteArrayList introduced? ArrayList is a List implementation in java collections. ArrayList is not threaded safe and can not be used in multi-threaded. applications. See the below example. Created ArrayList object. Iteration of each element loop using the Iterate method....


Learn how to implement an immutable class in java with examples

May 1, 2023 ·  3 min read

This post covers an example for Immutable objects in java Creating immutable with java 14 How to create an immutable class with mutable references What is an immutable class in java? An immutable class is a class once the class instance is created, Their content/state can not be changed. Each object has instance member variables and methods which change the state. Immutable classes with instance members are not changed their state via methods....


Naming style camel, snake,kebab, pascal cases tutorial example

May 1, 2023 ·  3 min read

programming Case name styles The string is a group of characters that contains word(s). A sentence is a group of strings or words In programming languages, there are different types of strings cases styles available There are various case styles for combing words to declare variables or functions or URLs in programming languages, This will be used as conventional notations only. All programming languages do not follow all cases....


Running Junit tests with jmockit in eclipse

May 1, 2023 ·  1 min read

Junit is a popular unit testing framework and jmockit is used to mock and fake the objects for testing API objects eclipse is my favorite IDE (integrated development environment) software tool that provides writing, debug, deploy code and existing test cases. eclipse provides plugins for JUnit and maven plugins After installing JUnit and Maven plugins to eclipse, we have to do the following steps JUnit and jmockit jars should be in the project classpath...


Scanner Class tutorial with examples in java

May 1, 2023 ·  3 min read

This blog post covers the scanner class tutorials with examples of Java language. Java.util.Scanner Class in java The Scanner class is one of the basic default classes provided by Java language as part of JDK installation. The Scanner class is located in the java.util package. Java.util.Scanner class is one way to take the input from the user keyboard in java. It read the input in the form of java primitive data types like Integer and String....


Sendgrid email tutorials in java with examples

May 1, 2023 ·  2 min read

Sendgrid is a SASS company, provides a transactional email provider and It is hosted on the cloud and enables integration in any application to send emails. In this tutorial, You learned how to create a java project and add SendGrid dependencies and send emails using SendGrid with example Create Java project using maven Maven has different archetypes for different applications generated for web and standard java projects. mvn archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -DarchetypeArtifactId=maven-archetype-quickstart -DarchetypeVersion=1....


Singleton Design pattern examples in java

May 1, 2023 ·  3 min read

Singleton design pattern in java Maintaining a single instance of an object in a system is called single design patterns. When we use the new Object() code to construct an object, one new instance is created; however, if we call these, several instances are created in heap memory. If the number of calls to new objects increases, the size of the object in heap memory grows, causing performance overhead. To prevent this, we’ll create a single object for all calls and return the same object....


Six ways to fix java.lang.NoClassDefFoundError in java

May 1, 2023 ·  5 min read

This article covers a solution for How to fix a NoClassDefFoundError in Java. The NoClassDefFoundError in Java is a strange error in Java applications. We used to get the Exception in thread “key” java.lang when we ran java programs. NoClassDefFoundError: I’ve seen this exception a lot of times in java applications. The solution to the NoClassDefFoundError is simple, but we must first understand how to solve it. The NoClassDefFoundError exception can exist in many circumstances, including Windows, Linux, Unix, and Tomcat/Websphere/JBoss....


Solution for com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type

May 1, 2023 ·  2 min read

In these tutorials, We are going to learn the fix for the following errors in spring or java applications. com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Java 8 date/time type java.time.LocalDate not supported by default: add Module “com.fasterxml.jackson.datatype:jackson-datatype-jsr310” to enable handling Java8 introduced many new classes for handling date and time in java.time package. This error will be thrown when you used the below classes in POJO fields for json conversion. LocalDateTime Instant LocalDate All java8 classes This tutorial covers for below things...


Solution for java.lang.StackOverflowError exception in java

May 1, 2023 ·  2 min read

StackOverflowError is one of the frequent exceptions/issues in java projects. These exceptions should not be caught by the programmer but thrown by Java virtual machine at runtime. whenever this exception is thrown, the application stopped its execution java stack overflow error class overview:- StackOverflowError extends java.lang.VirtualMachineError class which in turns extends java.lang.Error. so what is java.lang?Error?. Error class extends Throwable class specifies unusual errors that application unable to catch these exceptions....


Solutions for Frequently occurred exceptions in java language

May 1, 2023 ·  3 min read

Java Exception solutions Exception handling is a basic part of Java application development. It helps to make the application stable and error-free. When the application results error, java handles using exception classes. The Exception handle uses try, catch, and finally blocks. During development, Developers used to encounter different types of exceptions frequently. This post is about listing out the list of common exceptions, and solutions for fixing them. Following are the exceptions in a java programming language....


Spring boot cors issue

May 1, 2023 ·  2 min read

These are short tutorials on how to count the number of instances/objects of a class in java. An object of a class is created using a new keyword in java. an object is an instance of a class. A class can have multiple objects. How do you count the number of objects/instances of a class in java? static is the global scope that can be created and accessed by all objects of a class....


Spring RestTemplate - consume paginated response API java

May 1, 2023 ·  3 min read

RestTemplate in spring is used to consume REST API simplifying the process for the developer. It includes HTTP connection handling and is integrated with Jackson library binding to serialize and deserialize Java objects to/from json objects. It is easy to integrate external APIs in Java and Android codebases. This tutorial will not cover creating REST API in java. How to consume plain json data using RestTemplate Let’s assume that REST API returns the following json data....


Statement,PreparedStatement and CallableStatement in java JDBC with examples

May 1, 2023 ·  3 min read

In JDBC, statements use to execute the SQL queries in databases. We can send the simple SQL, complex SQL, and PL/SQL queries using these statements. There are three types of Statements. Statement PreparedStatement CallableStatement a Connection object is required to create any statement object. Here is java code to create connection object Class.forName("sun.jdbc.odbc.JdbcOdbcDriver"); Connection con= DriverManager.getConnection("jdbc:odbc:orc", "scott", "tiger"); Statement in JDBC It is a simple Statement to execute SQL queries like insert, update, and delete operations....


Static Import in java with examples| Difference between static vs normal import

May 1, 2023 ·  3 min read

Static Import in java 5 static import is a java language feature introduced in version 5 alias code name as tiger version. It was introduced to simplify the access of static variables and static members without using class names. Before static import is introduced, we have normal import statements for every java class to use the methods and classes with using the class name. Here is a normal import for List class example...


Tomcat Basics- How to set up and Latest install tomcat 9 server in windows?

May 1, 2023 ·  5 min read

In this blog post, We will cover the installation of Tomcat 9 on windows10 and Linux. Apache tomcat server basics Tomcat is an application server that supports running java,j2ee based applications. Tomcat is an open-source application server built on a java framework. It is used for web application deployment on this server. Tomcat 9 supports Servlet4 and Jsp 2.3. Tomcat runs applications using the HTTP protocol over TCP/IP protocol. The default port for tomcat installation is 80....


top 10 curl post request examples

May 1, 2023 ·  2 min read

Sometimes, you developed APIs in a local machine using spring boot or nodejs framework. You want to test those APIs in windows or Linux using the curl command. curl is a command-line tool to issue a request and transfer the data between two machines. type curl –help to know more about curl options curl --help Here is the syntax of the curl post command curl -X POST [option] [APIURL] curl is a command-line utility by default works in windows and Linux -X represents the request type i....


Top 15 Examples of HashMap in java | HashMap tutorial

May 1, 2023 ·  4 min read

This tutorial explains HashMap basics in java and features and top 15 examples. Contents How HashMap works in java Important points to remember for HashMap How to Create HashMap Object using java? How to add Objects to HashMap How to iterate through values HashMap? How to Find out the size of the hashmap How to Check if the key object exists in HashMap Check if value object available in HashMap How to delete an object from HashMap?...


Top 3 Examples of variable arguments| varargs feature in java

May 1, 2023 ·  2 min read

java variable arguments in methods: Learn with syntax and examples. What are Variable Arguments in java Variable arguments feature is one of the java language feature introduced in Java5. Java5 introduced a lot of new features like the Enum feature[] etc. Before Java5, methods can have multiple arguments, but the number of arguments is fixed. With Java5, the method can have multiple parameters (zero to many) to be supplied without having to define many arguments by specifying variable argument syntax....


Top 3 Java Text Formatting examples| MessageFormat class in java

May 1, 2023 ·  2 min read

java MessageFormat Text Formatting: Learn with syntax and examples. Why MessageFormat is introduced? the disadvantage with String class processing is Strings are immutable objects, more objects are created in heap memory and these messages order is not same for every language, because of this problems, Sun has introduced text format classes like MessageFormat Strings are immutable objects, which means that many objects are created in heap memory, and the order of these strings varies by programming language....


volatile keyword in java with example?

May 1, 2023 ·  2 min read

Volatile Keyword in java Volatile is a keyword in java that is used to change the value during multiple threads’ access to it. It applied to member variables only. We have another keyword transient for variable declaration in java. What happens if we declare a transient member variable in an object during a multi-thread application? In multithreaded applications, the state of any object can be modified asynchronously by multiple threads....


What contains inside Java Virtual Machine with the explanation

May 1, 2023 ·  3 min read

As you know in any machine, we have different components like hardware (physical machine call it as hardware(CPU, RAM.. etc) and software (Operating System). if you want to perform any operation from another machine, we need to write some code (say in c language) which will open a socket connection, that is a remote network call to another machine and make an OS call i.e native call. Each machine should have different ways to handle this situation....


what is the difference between derby and MySQL database

May 1, 2023 ·  2 min read

This post covers the comparison of derby and MySQL databases. MYSQL database: MySQL is an open-source from Oracle corporation, initially released in 1995, and supports all programming languages. It is written in C and C++ languages. They are accessed by Client-side libraries using JDBC/ODBC/native API. It is best suitable for the small range to mid-range applications. It uses in mobile and web applications of the following types eCommerce CRM applications Employee management ERP applications school management LMS systems MYSQL hosting is supported by popular providers like AWS, Azure, and Google cloud...


What is the use of javap command in java?

May 1, 2023 ·  2 min read

javap is the tool provided by the java language which was bundled with JDK software. javap tool is located in the JAVA\_HOME\\bin location which is used by many Java developers to find the member variables and methods for any Java object. It also has an option to provide byte code of a java class Syntax javap Options Classes Classes: single or multiple classes with the complete package name, for example, java....


Why the main method is declared as static in java?

May 1, 2023 ·  1 min read

In a simple java program, we declared the main method as the following way. public static void main(String args\[\]) { } The method name is main By using the java filename command, JVM loads the Java class into the memory and looks for the main class in the java file. if the main method is not found, it throws the NoClassFoundError exception. if the main method found, it will start the java execution code process....


Puppeteer Login Test example

March 13, 2023 ·  2 min read

Puppeteer is a nodejs library that is used to test webpages in a headless browser. It opens chromium in a headless browser. Create a Directory puppeteertest mkdir puppeteertest cd puppeteertest First, Create a nodejs project using the below command. npm init -y this creates a nodejs project with the required basic configuration. Install puppeteer dependency npm install puppeteer --save It installs the puppeteer into a node project. create a test.js file and add js code to it....


Fix for Core Web Vitals Assessment: Failed

February 18, 2023 ·  1 min read

PageSpeed insights is a tool used to measure the performance of an website. I am testing one of the website, got an message Core Web Vitals Assessment: Failed Core Web Vitals Assessment is a performance measurement for a website. It contains failed or Passed message based on following three metrics. Largest Contentful Paint or LCP First Input Delay or FID Cumulative Layout Shift or CLS ...


Groovy on Grails framework in java

February 18, 2023 ·  2 min read

Groovy on Grails is an open-source application framework build on java language using groovy scripting languages. what is the groovy framework:- Groovy is a scripting programming language that runs on a java virtual machine. Groovy is a java module that has one dependency jar file. Groovy is a scripting framework for building applications on top of java. It will reduce a lot of java code to write the applications and the files are saved with extension as ....


Instant. page - improve performance for websites with preload

February 18, 2023 ·  2 min read

This short tutorial talks about instant.page tool, how to improve website page performance. The instant.page allows to just in time preload/prefetch the URL, which does mean to load the URL before loading/clicking on it. How does the prefetch url work? the website has a lot of internal anchor links, User clicks on them and navigates to the page. This is usual user action on site. With the Instant.page tool, It automatically prefetches URLs in the background before the user comes to click the link as well as hovering the link....


Learn about changelog in github|gitlab example

February 18, 2023 ·  3 min read

In software application development, code is stored in code repositories like git, and bitbucket, Every feature in the application is committed with a change log and version number. During the application release process, the application version is increased For example, windows are released to the end-users with version 10,11 with each version containing features. What is the changelog? Changelog is a text file with a log summary of all your change made for each version of the project....


Learn XML and JSON basics with examples

February 18, 2023 ·  3 min read

In this blog post, We will discuss XML and JSON basics, pros/cons, and also convert JSON to XML or XML to JSON in java. What is JSON? JSON is abbreviated as javascript Object Notation. JSON is the independent format for exchanging data JSON is a simple format that contains key-pair values. JSON and XML are data formats used to transfer data between different systems of enterprise applications. JSON is lightweight and simple to read....


REST API basics tutorials with examples

February 18, 2023 ·  2 min read

REST is one of the popular web services in the software world. REST is abbreviated as Representational State Transfer. REST API used to develop HTTP-based web services REST is similar to SOAP web services, SOAP web services can be accessed using objects and methods, whereas REST can be accessed using URLs with HTTP operations like GET, POST, DELETE, and PUT. REST API is used to write the API for web applications to access the services....


Sendgrid from address does not match a verified Sender Identity

February 18, 2023 ·  2 min read

This article discusses how to solve the issue of a SendGrid email from address authentication. Sendgrid is an email provider that uses to send emails in applications written in java, golang, .net, and nodejs. When I tried to send emails using a java program, I received the following error. The from address does not match a verified Sender Identity. Mail cannot be sent until this error is resolved. Visit https://sendgrid.com/docs/for-developers/sending-email/sender-identity/ to see the Sender Identity...


Top 30 Cron job scheduler expression examples

February 18, 2023 ·  3 min read

Cron expressions are fixed-size string formatted characters used in scheduler programming to represent a set time or set of range of interval times. Cron expressions are implemented in both Unix and other programming languages, such as Java. The quartz framework in Java is used as a scheduler to execute jobs or tasks at defined time intervals. In the Quartz scheduler, cron expression is declared for job triggers that execute in the quartz scheduler....


Puppeteer Page Load navigation waiting example

February 16, 2023 ·  4 min read

Puppeteer is a nodejs library that is used to test webpages in a headless browser. It opens chromium in a headless browser Create a Directory puppeteertest mkdir puppeteertest cd puppeteertest First, Create a nodejs project using the below command npm init -y this creates a nodejs project with the required basic configuration. Install puppeteer dependency npm install puppeteer --save `` It installs the puppeteer into a node project create a test....


Best 10 Java Array Sort examples with strings numbers and objects

January 11, 2023 ·  6 min read

Contents Arrays Sort Examples Arrays.sort method java examples How to Sort an Array of Numbers in ascending order? How to sort integer arrays in descending order? How to sort String arrays in ascending order? How to sort String arrays in descending order? How to sort a Two-dimensional array in java? How to sort and merge integer arrays in java? How to sort Custom Object Arrays in ascending or descending order?...


Best 10 java.math.BigInteger class Examples with tutorials

January 11, 2023 ·  3 min read

In this blog post, learn How to Convert Integer/int from/to Biginteger with examples. You can also check my previous posts on BigInteger class tutorials in java. You can also check my previous posts on the BigInteger class in java. BigInteger Class tutorials Convert BigInteger to/from BigDecimal Convert BigDecimal to/from String BigInteger Divide example BigInteger Multiplication example Convert BigDecimal to float Convert BigDecimal to double Rounding bigdecimal to 2 decimal places Check BigDecimal contains Zero or not Convert BigInteger to/from ByteArray BigInteger Examples BigInteger is a Java class defined in java....


BigInteger tutorial with example in java

January 11, 2023 ·  3 min read

In this blog post, We are going to learn the BigInteger tutorial with an example in java. You can also check my previous posts on BigInteger class in java You can also check my previous posts on the BigInteger class in java. Convert BigInteger to/from BigDecimal Convert BigDecimal to/from String BigInteger Divide example BigInteger Multiplication example Convert BigDecimal to float Convert BigDecimal to double Top 10 BigInteger Examples(/2018/09/best-10-javamathbiginteger-class.html) Rounding bigdecimal to 2 decimal places Check BigDecimal contains Zero or not Convert BigInteger to/from ByteArray BigInteger Class in java BigInteger is one of the java objects in java....


How to convert BigDecimal to/from String in java examples

January 11, 2023 ·  4 min read

In this blog post, We are going to learn about BigInteger examples on Create BigInteger object using constructor, Example new BigInteger(123) How to Convert String from BigDecimal How to convert BigDecimal to String Other posts on BigInteger class in java You can also check my previous posts on the BigInteger class in java. BigInteger Class tutorials Convert BigInteger to/from BigDecimal BigInteger Divide example BigInteger Multiplication example Convert BigDecimal to float Convert BigDecimal to double Top 10 BigInteger Examples(/2018/09/best-10-javamathbiginteger-class....


How to convert BigInteger to BigDecimal or BigDecimal to BigInteger in Java with example

January 11, 2023 ·  3 min read

In this blog post, learn How to Convert BigInteger from/to BigDecimal with examples. BigInteger and BigDecimal examples Integer, Long, and Double are basic numeric primitive types that store numeric values up to a limited range of values for basic arithmetic operations. BigInteger is used to store large numeric values. BigDecimal is used to store the correct precision and rounding numbers where precision is important in financial applications. BigInteger and BigDecimal are classes in the java....


How to Convert BigInteger to String or String to BigInteger in java with examples?

January 11, 2023 ·  3 min read

Learn to Convert BigInteger from/to String with examples. You can also check my previous posts on the BigInteger class in java. BigInteger Class tutorials Convert BigInteger to/from BigDecimal Convert BigInteger to/from Integer/Int BigInteger Divide example BigInteger Multiplicationcationcation example Convert BigDecimal to float Convert BigDecimal to double Top 10 BigInteger Examples(/2018/09/best-10-javamathbiginteger-class.html) Rounding bigdecimal to 2 decimal places Check BigDecimal contains Zero or not Convert BigInteger to/from ByteArray BigInteger Object in Java BigInteger is commonly used for storing the numerical big values by the result of arbitrary arithmetic calculations....


How to convert BigInteger to/from Integer in java?

January 11, 2023 ·  4 min read

In this blog post, We are going to learn How to Convert Integer/int from/to Biginteger with examples. You can also check my previous posts on the BigInteger class in java. BigInteger Class tutorials Convert BigInteger to/from BigDecimal Convert BigDecimal to/from String BigInteger Divide example BigInteger Multiplication example Convert BigDecimal to float Convert BigDecimal to double Top 10 BigInteger Examples(/2018/09/best-10-javamathbiginteger-class.html) Rounding bigdecimal to 2 decimal places Check BigDecimal contains Zero or not Convert BigInteger to/from ByteArray java....


How to Install and setup homebrew on MacOS

January 11, 2023 ·  2 min read

This tutorial explains about following things How to Install Brew on MACOS Brew command not found What is the brew command in macOS Brew alias HomeBrew is an open-source package manager for macOS. It is a command line utility to manage the software or tools on macOS. You can install java, postman chrome, etc manually. It does not come with MACOS installation, You need to install it manually. Let’s see how to install brew on macOS Required...


Java Example - Convert BigInteger to Byte Array or Byte Array to BigInteger

January 11, 2023 ·  2 min read

In this blog post, We are going to learn How to Convert ByteArray from/to BigInteger with examples. You can also check my previous posts on BigInteger class in java. BigInteger Class tutorials Convert BigInteger to/from String Convert BigInteger to/from BigDecimal Convert BigDecimal to/from String Convert BigInteger to/from Integer/int Convert BigInteger to/from Integer/int Top 10 Big Integer examples Convert BigInteger to/from ByteArray BigInteger Example ByteArray is an array of bytes. Each byte is 8 bits of binary data....


Multiple ways to iterate Map and HashMap in Java with examples

January 11, 2023 ·  2 min read

This tutorials explains multiple ways to iterate key and values of a Map in java. There are multiple ways to iterate in HashMap and Map in java Iterator and Map.entrySet with java 4 version using for loop java8 foreach iterate with keySet,entrySet and values Let’s declare an HashMap with Key of String and value of Integer. Insert data into map using below code for example. HashMap<String, Integer> words = new HashMap<>(); words....


Data transfer object(DTO) Design Pattern in java examples

January 1, 0001 ·  3 min read

This post covers a Data transfer object(DTO) covers an example and naming conventions. The Data Transfer Object (DTO) design pattern is one of the design patterns used to transfer data from one system to another. These are also called Transfer Object or Value Object Why is the Data Transfer Objects pattern required? We must retrieve data from the database in the majority of java projects Database. In a method of a java class, you query the databases from your application (for example, select employee id, employee name from employee)....


Subscribe
You'll get a notification every time a post gets published here.