public class ReverseString { public static void main(String[] args) { String s1 = "neelendra"; for(int i=s1.length()-1;i>=0;i--) { System.out.print(s1.charAt(i)); } } }
String str = String.format( "Hello \n World \n my name is %s and i'm %d years old" , "Paul", 27);
static String valueOf(int i) - returns the string representation of the int argument.
public char charAt(int index) ----------------------------- String x = "airplane"; System.out.println( x.charAt(2) ); // output is 'r'
public boolean equalsIgnoreCase(String s) ------------------------------------------ String x = "Exit"; System.out.println( x.equalsIgnoreCase("EXIT")); // is "true" System.out.println( x.equalsIgnoreCase("tixe")); // is "false"
public String trim() String x = " hi "; System.out.println( x + "x" ); // result is" hi x" System.out.println(x.trim() + "x"); // result is "hix"
System.out.println("abc"); String cde = "cde"; System.out.println("abc" + cde); String c = "abc".substring(2,3); String d = cde.substring(1, 2);
char data[] = {'a', 'b', 'c'}; String str = new String(data);
String str = "abc";
public String concat(String s) String x = "book"; System.out.println( x.concat(" author") ); // output is "book author"
In java, string is an object. It is sequence of character values enclosed by double quotes.
String newString = "Hello World";