How to split String in java

String API provides 2 methods to split String in java. [crayon-5bc7eefcec4a0745916233/] Both these methods return a array of String that has been split. In this post we will see some examples using both these methods. 1. Split String using split(String regex) In

Read More

How to convert String to long

In Java we have multiple ways to convert String to long. We will see a few of those ways in this post. 1. Convert String to long using Long.parseLong() [crayon-5bc7eefced15b205113116/] If the String value doesn’t contain all digits OR if the String

Read More

How to convert String to Date

In this post we will see how to convert String to date in java. For this we will use SimpleDateFormat API to convert string to date. We need to pass in the dateformat in which we want to convert String to date

Read More

How to compare Strings in java

We can compare Strings in java either using [crayon-5bc7eefcedd7d852985235-i/] or [crayon-5bc7eefcedd86482328074-i/] depending on how the String was created. Using == to compare Strings in java == operator will check the reference of the Strings. If the references are same then == will

Read More

How to convert String to boolean

In Java we have multiple ways to convert String to boolean. We will see a few of those ways in this post. 1. Convert String to boolean using Boolean.parseBoolean() For Any value of string other than “true” (case insensitive), parseBoolean() will return

Read More

How to convert String to int

In Java we have multiple ways to convert String to int. We will see a few of those ways in this post. 1. Convert String to int using Integer.parseInt() [crayon-5bc7eefceea15851783713/] If the String value doesn’t contain all digits OR if the String

Read More

String Pool in Java and String Initialization

How to Create a String As we know that String in java can be created using 2 types. 1. Direct initialization [crayon-5bc7eefcef0a2752604352-i/] 2. Using a new operator [crayon-5bc7eefcef0ab484889294-i/] Difference between these 2 types Before going to the differences, we will first understand

Read More

Spring MVC Password tag Example

Spring MVC password tag is used to show a password field on the UI [crayon-5bc7eefcef6e3790704376/] The HTML code that gets generated is [crayon-5bc7eefcef6eb330656565/] You can get more information on the various attributes that can be used in the password tag at the

Read More

How to Create Dir in java

We can create dir in java either using [crayon-5bc7eefcefc90667106721-i/] or [crayon-5bc7eefcefc99312539468-i/]. Example: Create Dir in java using File.mkdir() [crayon-5bc7eefcefc9e582381544/] File.mkdir is used to create a directory that is given in the path. If we specify “C:\\kscodes\\work” as in the above example, then

Read More

How to Copy File in java

There are many ways in which you can copy file in java. Example : Copy File in java using InputStream/OutStream In the first example we will see the traditional way of copying file using the InputStream/OutStream. This is the method used prior

Read More