Simple string example

Simple string example

Previous Home Next

 

This example shows how the string object created and used.


String is the set of characters. or string represent the set of characters.
 


Create string objects str1,str2,str3. string is pass to  str2 and str3 .

 


 

package Example;

public class StringExample {

	
	public static void main(String[] args) {
		String str1 = new String("");
		 String str2 = new String("Hello R4R");
		 String str3 = "Hello R4R";
		 System.out.println( str3.length());
		
	}

}


9

The length of the str3 is 9.including space between  Hello and R4R.

Previous Home Next