Java String intern Example
String class intern method example
String class intern method example. This example shows you how to use intern method.This method Returns a canonical representation for the string object.
Syntax:-intern()
Here is the code:-
/**
* @(#) Internstring.java
*Program that Returns a canonical representation for the string object.
* @Version 02-May-2008
* @author Rose India Team
*/
public class Internstring
{
public static void main(String args[])
{
// Declaration of String
String s1 = "Welcome to Rose india Rose";
//Returns a canonical representation for the string object.
String s2 = s1.intern();
//Displaying the given String defined above
System.out.println(s2);
//Verifying wheather String S1 & S2 are equal or not
System.out.println(" Is (s1 == s2):- " + (s1 == s2));
}
} |
null
|