Search Java Programs

Wednesday, January 20, 2010

Java String isEmpty Example

String class isEmpty method example


String class isEmpty method example:- This method returns boolean value true if and only if .length methodreturns for the object taken under process and returns false if object chosen is not empty that means it has .length() method value greater than zero.

Syntax:- isEmpty()

Here is the code:-

 /**
* @ # StringArray3.java
* A class repersenting how Convert
* string array to a collection
* version 04 June 2008
* author Rose India
*/

import java.util.*;
public class StringArray3 {
public static void main(String args[]){
String arr[] = {"Zero", "One", "Two"};

//Convert string array to a collection
Collection l = Arrays.asList(arr);
ArrayList list = new ArrayList(l);

System.out.println("list = " + list);
}
}
Output of the program:-
length of the method is returned: 5
Method returns false here: false

No comments:

Post a Comment

Website Design by Mayuri Multimedia