使用java理解程式邏輯(15)

來源:互聯網
上載者:User

標籤:package   animal   substr   引用   字串拼接   tin   scan   string   使用   

package three;//聲明包
import java.util.Scanner;//匯入系統包
import one.two.School;//匯入使用者包
import one.two.Animal;//建議使用:不浪費記憶體
import one.two.*;//*代表one.two包下所有類(不建議使用:浪費)

 

一般字元串:字串有自動最佳化能力 定義時發現記憶體存在 直接引用

對象字串 只能用equals 不能用==

 

equalsIgnoreCase()   忽略大小寫比較

 

concat只能跟字串拼接

+字串和任何類型都可以拼接

 

indexOf 
indexOf       從左往右找 第1個 返回原字串所在索引
lastIndexOf     從右往左找 第1個 返回原字串所在索引

int a=email.indexOf("2",6);//子字串 在 原字串中所在的索引 -1:不存在 >=0存在

 

substring:截取字串

String email="[email protected]";
String b=email.substring(9,11);//從9索引截取到11索引前面一個(結束索引不截取)

 

split拆分字串 -->數組  

使用java理解程式邏輯(15)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.