-
/*Java String isEmpty Example.This Java String isEmpty example shows how to check whether the givenstring is empty or not using isEmpty method of Java String class.*/public class JavaStringIsEmptyExample {public static void main(String args[]){
String str1 = “”;String str2 = null;String str3 = “Hello World”;
/** To check whether the String is empty or not, use* boolean isEmpty() method of Java String class.** This method returns true if and only if string.length() is 0.*/
System.out.println(“Is String 1 empty? :” + str1.isEmpty());
//this will throw NullPointerException since str2 is null//System.out.println(“Is String 2 empty? :” + str2.isEmpty());System.out.println(“Is String 3 empty? :” + str3.isEmpty());
/** Please note that isEmpty method was added in JDK 1.6 and it is not available* in previous versions.** However, you can use* (string.length() == 0) instead of (string.isEmpty())* in previous JDK versions.*/}}
/*Output of Java String isEmpty would beIs String 1 empty? :trueIs String 3 empty? :false*/
Friday, 13 April 2018
Popular Posts
-
Build interactive, data-driven websites with the potent combination of open-source technologies and web standards, even if you have only ...
-
Java :- It is a fast, secure and reliable general purpose computer programming language. Python :- A Readable, efficient and powerfu...
-
Business Analytics Definition "Study of business data using statistical technique and programming for creating decision suppo...
-
Variables in R A variables are nothing but reserved memory locations to store values. This means that when you create a variab...
-
What is Python? → Python is an interpreted High level programming Language for General purpose programming. Python is created by Gui...
-
Why do we need Analytics ? → Data analytics helps organizations harness their data and use it to identify few opportunities. - Cost re...
-
- > is the prompt sign in R - The assignment operators are the left arrow with dash <- and equal sign =. > x <- 20 ...
-
Java is develop by James Gosling in 1991 Java is a developed in the early 90s in Sun Microsystems company. Java first version release in ...
-
Importing Data Files Spreadsheet (Excel) file data The xlsx package has the function read.xlsx ( ) for reading Excel files. This ...
-
1. Simple & Easy To Learn Open Source High-level Interpreted Large community 2. Portable & Extensible 3. Web ...

ReplyDeletenice article for beginners.thank you.
javacodegeeks
welookups java