A: Preface
Replace you always forget that the parameter is the one that replaced it, and I got the Replace method all over again.
II: Content
1 PackageOrg.replacedemo;2 3 Public classReplaceDemo01 {4 Public Static voidMain (String args[]) {5String a= "222222121231";6A=a.replace (' 2 ', ' a ');7System.out.println ("A.replace (OldChar, Newchar):" +a);8System.out.println ("---------------------");9A=a.replacefirst ("A", "B");TenSystem.out.println ("A.replacefirst (regex, Replacement):" +a); OneSystem.out.println ("########################"); AA=a.replace ("B", "C"); -System.out.println ("A.replace (target, replacement):" +a); -System.out.println (""); theA=a.replaceall ("A", "D"); -System.out.println ("A.replacefirst (regex, Replacement):" +a); - CharD= ' h '; - //a.replace (OldChar, Newchar);//Replace the previous + //A.replace (target, replacement); - //A.replaceall (regex, replacement); + //A.replacefirst (regex, replacement)//Replace the first one A } at}
Three: summary
This is my own to leave the company, first put their own things to tidy up. is to write trivial knowledge points.
Java Replace method