zoukankan      html  css  js  c++  java
  • Java面向对象_常用类库api

    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

  • 相关阅读:
    android:重写返回键动画
    获得今天零点时间戳(转)
    【转】完美解决Android 9.0以上HTTP网络请求被限制问题
    Java的三种取整方法
    thymeleaf控制checkbox的选中状态回显
    thymeleaf控制checkbox的value值
    Supervisor 简单使用
    关于Requests代理,你必须知道的
    py-spy 常见问题及使用说明
    记一次Scrapy进程卡死的Debug过程
  • 原文地址:https://www.cnblogs.com/shenhainixin/p/5085866.html
Copyright © 2011-2022 走看看