Commonly used methods of Java String Common class

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.