Strings in java code example
Example 1: how to make a string java
String newString = "Hello World";
Example 2: declare String in java
String stringName = "your string content";
Example 3: java string methods
static String valueOf(int i) - returns the string representation of the int
argument.
Example 4: string java
System.out.println("abc");
String cde = "cde";
System.out.println("abc" + cde);
String c = "abc".substring(2,3);
String d = cde.substring(1, 2);
Example 5: string method example in java
public char charAt(int index)
-----------------------------
String x = "airplane";
System.out.println( x.charAt(2) ); // output is 'r'
Example 6: string method example in java
public boolean equalsIgnoreCase(String s)
------------------------------------------
String x = "Exit";
System.out.println( x.equalsIgnoreCase("EXIT")); // is "true"
System.out.println( x.equalsIgnoreCase("tixe")); // is "false"