Use of string methods

package com.liu.demo1;



import java.util.Arrays;

public class Demo {
public static void main(String[] args) {
// Use of string methods
//1.length (); return to the length of the string
//2.Charat (int index); return a character of a location
//3.Contains (String Str); Judgment if a string is included
String content = "You love me, I love you, sweet honey";
System.out.println(content.length());
System.out.println(content.charAt(0));
System.out.println (Content.Contains));
System.out.println(content.contains("i love you"));
System.out.println("-----------------------------------------");
//4.tochararray (); Return to the array of strings
//5.indexof (); return sub-string first appearance position
//6.lastIndexof (); Returns the last appearance in the string
System.out.println(Arrays.toString(content.toCharArray()));
System.out.println (content.indexof (",");
System.Out.println (Content.indexof (", 6)); // The following number represents 0-Length from the first few positions.
System.out.println (content.lastIndexof (",");
System.out.println("-----------------------------------------");
//7.trim (); space before and after the character
//8.touppercase (); Conversion of lowercase to uppercase TOLOWERCASE (); convert capital to lowercase
//9.Endswith (STR); Judgment is the end of STR, StartSwith (STR); judgment if the STR is beginning
String name = " I Love You,You Love I ";
System.out.println(name.trim());
System.out.println(name.toUpperCase());
System.out.println(name.toLowerCase());
System.out.println(name.endsWith("I "));
System.out.println(name.startsWith("I"));
System.out.println("-----------------------------------------");
//10.Replace (CHAR OLD, CHAR New); replacing the original string with new strings
//11.split (); Split a string
System.out.println (Name.Replace ("I", "I"));
String [] arr = name.split (""); // If you want to split by multiple symbols [,]] 中 放 符,
// If you encounter multiple spaces, you will only remove 1 "[,] +" can be split together with multiple symbols.
System.out.println(arr.length);
for (String s : arr) {
System.out.println(s);
}
System.out.println("-----------------------------------------");
//11.Equals compares equally equivalents to ignore the case
String s1 ="hello";
String s2 ="HELLO";
System.out.println(s1.equals(s2));//false
System.out.println(s1.equalsIgnoreCase(s2));//true
//12.compareto (); compare two numbers in the coded table
String a1 ="abc";
String a2 ="xyz";
System.out.Println (A1.Compareto (A2)); // is only more than the first number, if the first number is the second number
String a3 ="abcdef";
System.out.println (A1.Compareto (A3)); // If it is the same

}
}