Java Se 基礎系列(筆記),javase

來源:互聯網
上載者:User

Java Se 基礎系列(筆記),javase

java.lang.String類代表不可變的字元序列

String類常用方法:1.public char charAt(int index); -- 返回下標為index的字元

         2.public int length();

         3.public int indexOf(String str); -- 返回字串中第一次出現字串str的下標

           4.public int indexOf(String str, int fromIndex);

         5.public boolean equalsIgnoreCase(String another);  -- 忽略大小寫情況下判斷兩個字串是否相等

         6.public boolean startWith(String prefix); 相應的還有endWith

         7.public String subString(int beginIndex);  --返回從beginIndex起的子串

           8.public String trim(); -- 去除字串前後的空白符

         9.public static String valueOf(int num);  --可將基本類型轉為字串

         10.public String[] split(String regex); --可將一字串按照指定的分隔字元分割,返回分割後的字串數組

 

 

StringBuffer類代表可變的字元序列,可以對其字串進行改變

    常用方法:1.public StringBuffer append(..); -- 添加到末尾

         2.public StringBuffer insert(..); -- 插入

         3.public StringBuffer delete(int start, int end);

         4.public StringBuffer reverse(); --用於將字串倒序

 

 

基礎資料型別 (Elementary Data Type)封裝類

    int i = 100; // i 分配在棧上

    Integer i = new Integer(100); //此時分配在堆上

    public int intValue(); --返回封裝資料的int型值

    public static int parseInt(String s); -- 將字串解析為int型資料並返回該資料

    public static Integer valueOf(String s); -- 返回Integer對象,其中封裝的整型資料為字串s所表示

 

 

Math類:提供一系列的靜態方法,其方法的參數和傳回值類型一般為double

    random() -- 返回0.0 - 1.0 之間的隨機數

 

 

Flie類代表系統檔案名稱(路徑和檔案名稱)

常見構造方法:   public File(String pathname)  -- 建立一個名為pathname的對象

            / public File(String parent, String child)

File的靜態屬性:   String separator 儲存了當前系統的路徑分隔字元(正斜杠通用!!!)

常用方法:     --通過File對象訪問檔案的屬性

          1.public boolean canRead()

          2.public boolean canWrite()

          3.public boolean isDirectory()

          4.public boolean isFile()

          5.public String getName()

          6.public String getPath()

          --通過File對象建立空檔案或目錄(在該對象所指的檔案或目錄不存在的情況下)

          1.public boolean createNexFile()

          2.public boolean mkdir() -- 建立路徑

          3.public boolean mkdirs() --建立一系列路徑

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.