<th id="wu2k2"><s id="wu2k2"></s></th> <blockquote id="wu2k2"></blockquote>
  • <tr id="wu2k2"></tr>
  • <samp id="wu2k2"><tbody id="wu2k2"></tbody></samp><samp id="wu2k2"><tbody id="wu2k2"></tbody></samp>
  • 更多精彩內(nèi)容,歡迎關(guān)注:

    視頻號(hào)
    視頻號(hào)

    抖音
    抖音

    快手
    快手

    微博
    微博

    java charsequence

    文檔

    java charsequence

    CharSequence類(lèi)是java.lang包下的一個(gè)接口,此接口對(duì)多種不同的對(duì)char訪問(wèn)的統(tǒng)一接口,像String、StringBuffer、StringBuilder類(lèi)都是CharSequence的子接口。
    推薦度:
    導(dǎo)讀CharSequence類(lèi)是java.lang包下的一個(gè)接口,此接口對(duì)多種不同的對(duì)char訪問(wèn)的統(tǒng)一接口,像String、StringBuffer、StringBuilder類(lèi)都是CharSequence的子接口。

    java charsequence是什么,讓我們一起了解一下?

    CharSequence類(lèi)是java.lang包下的一個(gè)接口,此接口對(duì)多種不同的對(duì)char訪問(wèn)的統(tǒng)一接口,像String、StringBuffer、StringBuilder類(lèi)都是CharSequence的子接口。

    那么CharSequence接口是如何實(shí)現(xiàn)的?

    CharSequence接口的源碼如下:

    package?java.lang;
    /**
    ?*?A?CharSequence?is?a?readable?sequence?of?char?values.?This
    ?*?interface?provides?uniform,?read-only?access?to?many?different?kinds?of
    ?*?char?sequences.
    ?*?A?char?value?represents?a?character?in?the?Basic
    ?*?Multilingual?Plane?(BMP)?or?a?surrogate.?Refer?to?Unicode?Character?Representation?for?details.
    ?*
    ?*?

    ?This?interface?does?not?refine?the?general?contracts?of?the?{@link ?*?java.lang.Object#equals(java.lang.Object)?equals}?and?{@link ?*?java.lang.Object#hashCode()?hashCode}?methods.??The?result?of?comparing?two ?*?objects?that?implement?CharSequence?is?therefore,?in?general, ?*?undefined.??Each?object?may?be?implemented?by?a?different?class,?and?there ?*?is?no?guarantee?that?each?class?will?be?capable?of?testing?its?instances ?*?for?equality?with?those?of?the?other.??It?is?therefore?inappropriate?to?use ?*?arbitrary?CharSequence?instances?as?elements?in?a?set?or?as?keys?in ?*?a?map.?

    ?* ?*?@author?Mike?McCloskey ?*?@since?1.4 ?*?@spec?JSR-51 ?*/ public?interface?CharSequence?{ ????/** ?????*?Returns?the?length?of?this?character?sequence.??The?length?is?the?number ?????*?of?16-bit?chars?in?the?sequence.

    ?????* ?????*?@return??the?number?of?chars?in?this?sequence ?????*/ ????int?length(); ????/** ?????*?Returns?the?char?value?at?the?specified?index.??An?index?ranges?from?zero ?????*?to?length()?-?1.??The?first?char?value?of?the?sequence?is?at ?????*?index?zero,?the?next?at?index?one,?and?so?on,?as?for?array ?????*?indexing.?

    ?????* ?????*?

    If?the?char?value?specified?by?the?index?is?a ?????*?surrogate,?the?surrogate ?????*?value?is?returned. ?????* ?????*?@param???index???the?index?of?the?char?value?to?be?returned ?????* ?????*?@return??the?specified?char?value ?????* ?????*?@throws??IndexOutOfBoundsException ?????*??????????if?the?index?argument?is?negative?or?not?less?than ?????*??????????length() ?????*/ ????char?charAt(int?index); ????/** ?????*?Returns?a?new?CharSequence?that?is?a?subsequence?of?this?sequence. ?????*?The?subsequence?starts?with?the?char?value?at?the?specified?index?and ?????*?ends?with?the?char?value?at?index?end?-?1.??The?length ?????*?(in?chars)?of?the ?????*?returned?sequence?is?end?-?start,?so?if?start?==?end ?????*?then?an?empty?sequence?is?returned.?

    ?????* ?????*?@param???start???the?start?index,?inclusive ?????*?@param???end?????the?end?index,?exclusive ?????* ?????*?@return??the?specified?subsequence ?????* ?????*?@throws??IndexOutOfBoundsException ?????*??????????if?start?or?end?are?negative, ?????*??????????if?end?is?greater?than?length(), ?????*??????????or?if?start?is?greater?than?end ?????*/ ????CharSequence?subSequence(int?start,?int?end); ????/** ?????*?Returns?a?string?containing?the?characters?in?this?sequence?in?the?same ?????*?order?as?this?sequence.??The?length?of?the?string?will?be?the?length?of ?????*?this?sequence.?

    ?????* ?????*?@return??a?string?consisting?of?exactly?this?sequence?of?characters ?????*/ ????public?String?toString(); }

    另外CharSequence類(lèi)是一個(gè)描述字符串的一個(gè)描述型接口,有三個(gè)類(lèi)實(shí)現(xiàn)了該接口,分別為:String、StringBuffer、StringBuilder類(lèi),所以說(shuō),看到這個(gè)類(lèi),就直接當(dāng)做是一個(gè)字符串類(lèi)型就可以了,示例代碼如下:

    /**
    ?*?String、Stringbuffer、StringBuilder?三個(gè)字符相關(guān)的類(lèi)都實(shí)現(xiàn)
    ?*??????了CharSequence?類(lèi),所以說(shuō),以后見(jiàn)到CharSequence描述的就是字符串
    ?*/
    ?
    public?class?CharSequenceStudy?{
    ????public?static?void?main(String[]?args)?{
    ????????CharSequence?str?=?"www.ayit.com";
    ????????CharSequence?sub?=?str.subSequence(4,8);
    ????????System.out.println(sub);
    ????????System.out.println(str.length());
    ????}
    }

    拓展一下:對(duì)于抽象類(lèi)或者接口來(lái)說(shuō)不可以直接使用new的方式創(chuàng)建對(duì)象,但是可以直接給它賦值; CharSequence b = "s"; > 。CharSequence b = "s" 是一個(gè)類(lèi)型強(qiáng)轉(zhuǎn)操作,等于CharSequence b = (CharSequence) new String("s")。

    以上就是小編今天的分享了,希望可以幫助到大家。

    文檔

    java charsequence

    CharSequence類(lèi)是java.lang包下的一個(gè)接口,此接口對(duì)多種不同的對(duì)char訪問(wèn)的統(tǒng)一接口,像String、StringBuffer、StringBuilder類(lèi)都是CharSequence的子接口。
    推薦度:
    為你推薦
    資訊專(zhuān)欄
    熱門(mén)視頻
    相關(guān)推薦
    java charset java cipher java class java class.forname java classloader java clob java clone() java collect java collections java color java combobox java comet 山楂干泡水最佳搭配 java commandline java comparable接口 java compiler java config java console java console.log 復(fù)活節(jié)的由來(lái) java charat java channel iPad怎么重啟 java cglib 平板如何錄屏 java ceiling java callback java calendar獲取當(dāng)前時(shí)間 蘋(píng)果13怎么開(kāi)機(jī) java calculate java byte取值范圍 java bytebuffer java bundle java build.gradle java bufferedoutputstream java bufferedimage wps怎么求和 java break java blob java bit
    Top 在线播放精品一区二区啪视频| 亚洲精品国产日韩无码AV永久免费网| 伊人精品视频一区二区三区| 无码人妻精品一区二区三区9厂| 十八18禁国产精品www| 久久精品国产一区二区| 在线观看精品国产福利片尤物 | 国产在线国偷精品免费看| 国外AV无码精品国产精品| 国产精品va一级二级三级| 日韩精品人妻系列无码专区免费 | 含羞草国产亚洲精品岁国产精品| 久久青青草原精品国产| 久久国产精品国产自线拍免费| 国产精品最新国产精品第十页| 国产午夜久久精品| 亚洲精品宾馆在线精品酒店| 精品一区二区三区在线播放视频| 小辣椒福利视频精品导航| 人与狗精品AA毛片| 久久久久国产精品麻豆AR影院| 无码AⅤ精品一区二区三区| 老牛精品亚洲成av人片| 中文无码亚洲精品字幕| 精品国产无限资源免费观看| 182tv午夜精品视频在线播放| 蜜臀久久99精品久久久久久小说 | 亚洲av无码成人精品国产| 91久久精品国产免费直播| 久久国产精品无码一区二区三区 | 亚洲永久精品ww47| 久久精品国产精品亚洲人人| 国产精品亚洲综合一区| 国产精品理论片在线观看| 国产精品国产三级国产a| 亚洲精品无码成人片在线观看| 国产精品午夜高清在线观看| 国产亚洲精品91| 亚洲国产精品丝袜在线观看| 亚洲精品综合久久| 国产精品久久久久久久午夜片|