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

  • 相关阅读:
    使用FormData,进行Ajax请求并上传文件
    oracle视图详解
    Unicode和UTF-8之间的关系
    如何访问tomcat所在服务器的其他盘符的资源。
    React首次渲染过程
    react知识点总结
    WebSocket基础
    gulp 批量添加类名 在一个任务中使用多个文件来源
    Chrome浏览器取消INPUT自动记忆下拉框
    Angular7 Drag and Drop
  • 原文地址:https://www.cnblogs.com/shenhainixin/p/5085866.html
Copyright © 2011-2022 走看看