Javaの文字列の一般的な方法
1、Javaの文字列のいくつかの一般的な方法
2、結果
/**
*
*/
package com.you.model;
/**
* @author Administrator
* @date 2014-02-24
*/
public class Replace {
/**
* @param args
*/
public static void main(String[] args)
{
/**
*
*/
String str = "78454545855ksdjnf dnfdksf klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>";
/**
* concat()
*/
str = str.concat(str);
System.out.println(" concat():" + str);
System.out.println();
/**
* intern()
*/
str = str.intern();
System.out.println(" intern():" + str);
System.out.println();
/**
* replace("","")
*/
str = str.replace("8", " ");
System.out.println(" replace('',''):" + str);
System.out.println();
/**
* replaceAll("","")
*/
str = str.replaceAll("f", " ");
System.out.println(" replaceAll('',''):" + str);
System.out.println();
/**
* replaceFirst("","")
*/
str = str.replaceFirst("7", " ");
System.out.println(" replaceFirst('',''):" + str);
System.out.println();
/**
* substring()
*/
str = str.substring(20);
System.out.println(" substring():" + str);
System.out.println();
/**
* substring(, )
*/
str = str.substring(25, 35);
System.out.println(" substring(0,10):" + str);
System.out.println();
/**
* toLowerCase()
*/
str = str.toLowerCase();
System.out.println(" toLowerCase():" + str);
System.out.println();
/**
* toUpperCase()
*/
str = str.toUpperCase();
System.out.println(" toUpperCase():" + str);
System.out.println();
/**
* trim()
*/
str = str.trim();
System.out.println(" trim():" + str);
System.out.println();
/**
* length()
*/
int len = str.length();
System.out.println(" length():" + len);
}
}
2、結果
concat():78454545855ksdjnf dnfdksf klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>78454545855ksdjnf dnfdksf klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>
intern():78454545855ksdjnf dnfdksf klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>78454545855ksdjnf dnfdksf klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>
replace('',''):7 454545 55ksdjnf dnfdksf klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>7 454545 55ksdjnf dnfdksf klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>
replaceAll('',''):7 454545 55ksdjn dn dks klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>7 454545 55ksdjn dn dks klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>
replaceFirst('',''): 454545 55ksdjn dn dks klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>7 454545 55ksdjn dn dks klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>
substring():djn dn dks klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>7 454545 55ksdjn dn dks klkADE TGTH eiru oaK L!@@$#%$^*&(*()()><?<>>>
substring(0,10):ADE TGTH e
toLowerCase():ade tgth e
toUpperCase():ADE TGTH E
trim():ADE TGTH E
length():10