String toUpperCase method is used to converts all characters in a given string to upper case. String has 2 toUpperCase methods.
1 2 3 |
public String toUpperCase() public String toUpperCase(Locale locale) |
String toUpperCase method is used to converts all characters in a given string to upper case. String has 2 toUpperCase methods.
1 2 3 |
public String toUpperCase() public String toUpperCase(Locale locale) |
String toLowerCase method is used to converts all characters in a given string to lower case. String has 2 toLowerCase methods.
1 2 3 |
public String toLowerCase() public String toLowerCase(Locale locale) |
String substring method is used to get a part of String using the start and end index. String had 2 substring methods.
1 2 3 |
public String substring(int beginIndex) public String substring(int beginIndex,int endIndex) |
String length method in java is used to get the length of a given string. String length method example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
package com.kscodes.sampleproject; public class StringLengthExample { public static void main(String[] args) { String testStr1 = "This is Test String for calculating length"; String testStr2 = "Another String"; System.out.println("The Length of testStr1 is ::" + testStr1.length()); System.out.println("The Length of testStr2 is ::" + testStr2.length()); } } |
1 2 |
The Length of testStr1 is ::42 The Length of testStr2 is ::14 |
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
String API provides 2 methods to split String in java.
1 2 |
public String[] split(String regex) public String[] split(String regex,int limit) |
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); |
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
We can compare Strings in java either using == or equals() depending on how the String was created. Using == to compare Strings in java ==
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