public static void Main (string[] args) {//TODO auto-generated method stub/* * Use for loop to iterate array * int arr[]=new int[]{};int arr 1[][]={{1,2,3,4,5,6,7,8,9},{2,3,6,8,7},{8,5,9,6,7}};for (int i = 0; i < arr1.length; i++) {for (int j = 0; J < arr1[ I].length; J + +) {int content=arr1[i][j]; System.out.print (content);} System.out.println ("\ n-----------------------------------------------------");} */string arr[]={"1", "2", "3", "4", "5", "3", "9"};////string text= "Hello.txt;study.java;word.php;hello.word.java; lastnone.c; "; /system.out.println (Text.indexof ("T"));//Returns the index of the first occurrence of T,---6//system.out.println (text.lastindexof ("a"));// Returns the index position of the last occurrence of a string--47//system.out.println (Text.lastindexof (". Java"));//Returns the last occurrence of the. Java Index location--47//char ch= Text.charat (4);//Returns a char-type string//string re=ch+ "";//system.out.println (Re.touppercase ());//touppercase () ; The lowercase letter is converted to uppercase, and the return type is String type//system.out.println (Text.charat (4));//returns the character with the string index value 4 as O//SYSTEM.OUT.PRINTLN (" The length of the string is: "+text.length ());//-----------------------------------------------------------------------------------------------------------------------//Find the string in the string ending in. java, delimited by; String text= "HELLO.TXT;STUDY.JAVA;WORD.PHP;HELLO.WORD.JAVA;LASTNONE.C;"; String rest[]=text.split (";"); /Use the Split method to split the string, return an array of string, must use a string array to receive the for (String i:rest) {int Re=i.lastindexof (". Java"); if (re>0) {// Determine if each string has a. Java end, there is the output, did not skip into the next cycle System.out.println (i);} Else{continue;}} Use the Foreach loop to iterate through the array, for (element variable x: traversed object obj) {Reference X's Java statement}//--------------------------------------------------------- --------------------------------------------------------------}
Commonly used methods of Java String Common class