String equals and equalsIgnoreCase are used for comparing 2 Strings in java.Both these methods works exactly similar except for equalsIgnoreCase compares String ignoring case consideration. example
How to split String in java
String API provides 2 methods to split String in java.
1 2 |
public String[] split(String regex) public String[] split(String regex,int limit) |
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()
1 2 |
String str1 = "500"; long convertedLong = Long.parseLong(str1); |
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 St
How to compare Strings in java
We can compare Strings in java either using == or equals() depending on how the String was created. Using == to compare Strings in java ==
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 tha
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()
1 2 |
String str1 = "500"; int convertedInt = Integer.parseInt(str1); |
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 String textString = "This is test"; 2. Using a new operator [crayon-68eba6c0d5d4665684483
Spring MVC Password tag Example
Spring MVC password tag is used to show a password field on the UI
1 |
<form:password path="password" /> |
1 |
<input id="password" name="password" type="password" value=""> |
How to Create Dir in java
We can create dir in java either using File.mkdir() or File.mkdirs(). Example: Create Dir in java using File.mkdir()
1 2 3 4 5 6 7 8 9 10 11 12 |
public static void createDir() { File directory = new File("C:\\kscodes"); boolean dirCreated = directory.mkdir(); if (dirCreated) { System.out.println("Directory Created Successfully !!!"); } else { System.out.println("Unable to create Directory"); } } |