- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 9321 Articles for Object Oriented Programming
![Abhinanda Shri](https://www.tutorialspoint.com/assets/profiles/13552/profile/60_73264-1512711555.jpg)
77 Views
You can change the cases using the toUpperCase() and toLowerCase() methods of the String class.ExampleLive Demopublic class Sample { public static void main(String args[]){ String str = "Hello how are you"; String strUpper = str.toUpperCase(); System.out.println("Lower to upper : "+strUpper); String strLower = str.toLowerCase(); System.out.println("Upper to lower : "+strLower); } }OutputLower to upper : HELLO HOW ARE YOU Upper to lower : hello how are you
![Ankitha Reddy](https://www.tutorialspoint.com/assets/profiles/13550/profile/60_73963-1512711511.jpg)
901 Views
The toUpperCase() method converts all of the characters in this String to upper case using the rules of the default locale The toLowerCase() method converts all of the characters in this String to lower case using the rules of the default locale. Example Live Demo import java.lang.*; public class StringDemo { public static void main(String[] args) { // converts all upper case letters in to lower case letters String str1 = "SELF LEARNING CENTER"; System.out.println("string value = ... Read More
![Srinivas Gorla](https://www.tutorialspoint.com/assets/profiles/13556/profile/60_78057-1512712331.jpg)
847 Views
ExampleLive Demoimport java.lang.*; public class StringDemo { public static void main(String[] args) { // converts all upper case letters in to lower case letters String str1 = "SELF LEARNING CENTER"; System.out.println("string value = " + str1.toLowerCase()); str1 = "TUTORIALS POINT"; System.out.println("string value = " + str1.toLowerCase()); // converts all lower case letters in to upper case letters String str2 = "This is TutorialsPoint"; System.out.println("string value = " + str2.toUpperCase()); str2 = "www.tutorialspoint.com"; System.out.println("string value = " + str2.toUpperCase()); } } Outputstring value = self learning center string value = tutorials point string value = THIS IS TUTORIALSPOINT string value = WWW.TUTORIALSPOINT.COM
![Ramu Prasad](https://www.tutorialspoint.com/assets/profiles/13539/profile/60_87996-1512650215.jpg)
180 Views
This method has two variants. The first variant converts all of the characters in this String to upper case using the rules of the given Locale. This is equivalent to calling toUpperCase(Locale.getDefault()).The second variant takes a locale as an argument to be used while converting into upper case.ExampleLive Demoimport java.io.*; public class Test { public static void main(String args[]) { String Str = new String("Welcome to Tutorialspoint.com"); System.out.print("Return Value :"); System.out.println(Str.toUpperCase()); } }OutputReturn Value :WELCOME TO TUTORIALSPOINT.COM
![Sravani S](https://www.tutorialspoint.com/assets/profiles/13538/profile/60_67753-1512711355.jpg)
286 Views
The split(String regex) method of the String class splits this string around matches of the given regular expression.ExampleLive Demopublic class Sample{ public static void main(String args[]){ String s = "|A|BB||CCC|||"; String[] words = s.split("\|"); for (String string : words) { System.out.println(string); } } }OutputA BB CCC
![V Jyothi](https://www.tutorialspoint.com/assets/profiles/13530/profile/60_77592-1512648869.jpg)
4K+ Views
The split(String regex) method of the String class splits this string around matches of the given regular expression.This method works in the same way as invoking the method i.e split(String regex, int limit) with the given expression and a limit argument of zero. Therefore, trailing empty strings are not included in the resulting array.ExampleLive Demoimport java.lang.*; public class StringDemo { public static void main(String[] args) { String str = "a d, m, i.n"; String delimiters = "\s+|, \s*|\.\s*"; // analysing the string String[] tokensVal = str.split(delimiters); ... Read More
![Priya Pallavi](https://www.tutorialspoint.com/assets/profiles/13562/profile/60_91320-1512544134.jpg)
884 Views
The StringTokenizer class allows an application to break a string into tokens.This class is a legacy class that is retained for compatibility reasons although its use is discouraged in new code.ExampleLive Demoimport java.util.*; public class Sample { public static void main(String[] args) { // creating string tokenizer StringTokenizer st = new StringTokenizer("Come to learn"); // counting tokens System.out.println("Total tokens : " + st.countTokens()); // checking tokens while (st.hasMoreTokens()) { System.out.println("Next token : " + st.nextToken()); ... Read More
![Jai Janardhan](https://www.tutorialspoint.com/assets/profiles/13513/profile/60_63529-1512538711.jpg)
107 Views
We can verify whether the given string is empty using the isEmpty() method of the String class. This method returns true only if length() is 0.ExampleLive Demoimport java.lang.*; public class StringDemo { public static void main(String[] args) { String str = "tutorialspoint"; // prints length of string System.out.println("length of string = " + str.length()); // checks if the string is empty or not System.out.println("is this string empty? = " + str.isEmpty()); } }Outputlength of string = 14 is this string empty? = false
![Govinda Sai](https://www.tutorialspoint.com/assets/profiles/13542/profile/60_86497-1512650655.jpg)
1K+ Views
The replace method of the String class accepts two characters and it replaces all the occurrences of oldChar in this string with newChar.Exampleimport java.io.*; public class Test { public static void main(String args[]) { String Str = new String("Welcome to Tutorialspoint.com"); System.out.print("Return Value :" ); System.out.println(Str.replace('o', 'T')); System.out.print("Return Value :" ); System.out.println(Str.replace('l', 'D')); } }OutputReturn Value :WelcTme tT TutTrialspTint.cTm Return Value :WeDcome to TutoriaDspoint.comThe replaceAll() method replaces each substring of this string that matches the given regular expression with the given replacement.Exampleimport java.io.*; ... Read More
![George John](https://www.tutorialspoint.com/assets/profiles/13511/profile/60_58410-1512537824.png)
12K+ Views
We can check whether a particular String is empty or not, using isBlank() method of the StringUtils class. This method accepts an integer as a parameter and returns true if the given string is empty, or false if it is not. Example Live Demo import org.apache.commons.lang3.StringUtils; public class Sample { public static void main(String args[]) { String str = ""; Boolean bool = StringUtils.isBlank(str); System.out.println(bool); } } Output true