Sting string manipulation

Source: Internet
Author: User

=============== Code ==================

Package com.cratd;


Import Java.util.Random;


public class Mymain {


/**

* @param args

*/

public static void Main (string[] args) {

TODO auto-generated Method Stub

int A;

Int[] B = new Int[5];

int[] x = new INT[3];

Int[] [] y= new INT[3] [5];

for (int i=0;i<3;i++) {

for (int j=0;j<5;j++) {

Y[i][j]=j+i;

}

}

for (int i=0;i<3;i++) {

for (int j=0;j<5;j++) {

System.out.print (y[i][j]+ "");

}

System.out.print ("\ n");

}

System.out.print ("\ n");

System.out.print ("\ n");

System.out.print ("\ n");

for (int i=0;i<5;i++) {

for (int j=0;j<3;j++) {

System.out.print (y[j][i]+ "");

}

System.out.print ("\ n");

}

int p=0;

Char ch= ' B ';

String s1= "Celloword";

String s2= "word";

Equalsignorecase

System.out.print (s1.equalsignorecase (S2));

System.out.print ("\ n");

CompareTo

System.out.print (S1.compareto (S2));

System.out.print ("\ n");

Startwith

System.out.print (S1.startswith (S2));

System.out.print ("\ n");

Endwith

System.out.print (S1.endswith (S2));

System.out.print ("\ n");

IndexOf

System.out.print (S1.indexof ("w"));

System.out.print ("\ n");

CharAt

System.out.print (S1.charat (5));

System.out.print ("\ n");

Substring

System.out.print (S1.substring (5));

System.out.print ("\ n");

System.out.print (s1.substring (3,6));

System.out.print ("\ n");

Concat

System.out.print (S1.concat (S1));

System.out.print ("\ n");

Replace

System.out.print (S1.replace ("word", "?"));

System.out.print ("\ n");

Trim

String s3= "word";

System.out.print ("^" +s3+ "^");

System.out.print ("\ n");

System.out.print (S3.trim ());

System.out.print ("\ n");

toUpperCase toLowerCase

String s4= "CRATD";

System.out.print (S4.touppercase ());

System.out.print ("\ n");

System.out.print (S4.tolowercase ());

System.out.print ("\ n");

}


}

============== Output ===================

0 1 2) 3 4

1 2 3) 4 5

2 3 4) 5 6




0 1 2

1 2 3

2 3 4

3 4 5

4 5 6

False

-20

False

True

5

W

Word

Low

Cellowordcelloword

Cello?

^ Word ^

Word

Cratd

Cratd


This article from "Boulevard to Jane, Heaven and Earth in My Heart" blog, please be sure to keep this source http://8392460.blog.51cto.com/8382460/1771574

Sting string manipulation

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.