码迷,mamicode.com
首页 > 编程语言 > 详细

Java面向对象_常用类库api

时间:2015-12-29 15:57:33      阅读:235      评论:0      收藏:0      [点我收藏+]

标签:

StringBuffer

例:

 1 public class StringBufferDemo {
 2 
 3     /**
 4      * @param args
 5      */
 6     public static void main(String[] args) {
 7         // TODO Auto-generated method stub
 8         //使用String的写法连接字符串,比较占内存
 9         String s="hello";
10         String ss=s+"world";
11         for(int i=0;i<10;i++){
12             s+="hello"+i;
13         }
14         System.out.println(s);
15         //StringBuffer
16         StringBuffer sb=new StringBuffer(100);//带容量
17         for(int i=0;i<10;i++){
18             sb.append(i);
19         }
20         System.out.println(sb);
21     }
22 
23 }

程序国际化Locale类

Locale(String language)

Locale(String language,String country)

通过静态方法创建Locale:

getDefault()

 1 public class LocaleDemo {
 2 
 3     /**
 4      * @param args
 5      */
 6     public static void main(String[] args) {
 7         // TODO Auto-generated method stub
 8         Scanner input=new Scanner(System.in);
 9         Locale locale=Locale.CHINA;
10         locale.getCountry();
11         
12         Locale locale2=new Locale("en","US");
13         
14         ResourceBundle rb=ResourceBundle.getBundle("com.vince.info",locale);
15         System.out.println(rb.getString("welcome"));
16         System.out.println(rb.getString("input.username"));
17         String username=input.next();
18         System.out.println(rb.getString("input.psw"));
19         String password=input.next();
20         if("abc".equals(username)&&"123".equals(password)){
21             
22             String info=MessageFormat.format(rb.getString("info"),"abc");//处理动态文本
23             System.out.println(info);
24         }
25     }
26 
27 }

实现国际化,要File->new->File

技术分享

Java面向对象_常用类库api

标签:

原文地址:http://www.cnblogs.com/shenhainixin/p/5085866.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!