StringBuffer
例:
public class StringBufferDemo { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//使用String的写法连接字符串,比较占内存
String s="hello";
String ss=s+"world";
for(int i=0;i<10;i++){
s+="hello"+i;
}
System.out.println(s);
//StringBuffer
StringBuffer sb=new StringBuffer(100);//带容量
for(int i=0;i<10;i++){
sb.append(i);
}
System.out.println(sb);
} }
程序国际化Locale类
Locale(String language)
Locale(String language,String country)
通过静态方法创建Locale:
getDefault()
public class LocaleDemo { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input=new Scanner(System.in);
Locale locale=Locale.CHINA;
locale.getCountry(); Locale locale2=new Locale("en","US"); ResourceBundle rb=ResourceBundle.getBundle("com.vince.info",locale);
System.out.println(rb.getString("welcome"));
System.out.println(rb.getString("input.username"));
String username=input.next();
System.out.println(rb.getString("input.psw"));
String password=input.next();
if("abc".equals(username)&&"123".equals(password)){ String info=MessageFormat.format(rb.getString("info"),"abc");//处理动态文本
System.out.println(info);
}
} }
实现国际化,要File->new->File