/*
string類適用於描述字串事物。
那麼它就提供了多個方法對字串進行操作。
常見的操作有哪些?
"abcd"
1,獲取。
1.1 字串中的包含的字元數,也就是字串的長度。
int length():獲取長度。
1.2 根據位置獲取位置上某個字元。
char charat(int index):
1.3 根據字元獲取該字元在字串中位置。
int indexof(int ch):返回的是ch在字串中第一次出現的位置。
int indexof(int ch, int fromindex) :從fromindex指定位置開始,獲取ch在字串中出現的位置。
int indexof(string str):返回的是str在字串中第一次出現的位置。
int indexof(string str, int fromindex) :從fromindex指定位置開始,獲取str在字串中出現的位置。
int lastindexof(int ch) :
2,判斷。
2.1 字串中是否包含某乙個子串。
boolean contains(str):
特殊之處:indexof(str):可以索引str第一次出現位置,如果返回-1.表示該str不在字串中存在。
所以,也可以用於對指定判斷是否包含。
if(str.indexof("aa")!=-1)
而且該方法即可以判斷,有可以獲取出現的位置。
2.2 字元中是否有內容。
boolean isempty(): 原理就是判斷長度是否為0.
2.3 字串是否是以指定內容開頭。
boolean startswith(str);
2.4 字串是否是以指定內容結尾。
boolean endswith(str);
2.5 判斷字串內容是否相同。複寫了object類中的equals方法。
boolean equals(str);
2.6 判斷內容是否相同,並忽略大小寫。
boolean equalsignorecase();
3,轉換。
3.1 將字元陣列轉成字串。
建構函式:string(char)
string(char,offset,count):將字元陣列中的一部分轉成字串。
靜態方法:
static string copyvalueof(char);
static string copyvalueof(char data, int offset, int count)
static string valueof(char):
3.2 將字串轉成字元陣列。**
char tochararray():
3.3 將位元組陣列轉成字串。
string(byte)
string(byte,offset,count):將位元組陣列中的一部分轉成字串。
3.4 將字串轉成位元組陣列。
byte getbytes():
3.5 將基本資料型別轉成字串。
static string valueof(int)
static string valueof(double)
//3+"";
特殊:字串和位元組陣列在轉換過程中,是可以指定編碼表的。
4,替換
string replace(oldchar,newchar);
5,切割
string split(regex);
6,子串。獲取字串中的一部分。
string substring(begin);
string substring(begin,end);
7,轉換,去除空格,比較。
7.1 將字串轉成大寫或則小寫。
string touppercase();
string tolowercase();
7.2 將字串兩端的多個空格去除。
string trim();
7.3 對兩個字串進行自然順序的比較。
int compareto(string);
*/class stringmethoddemo
public static void method_sub()
public static void method_split()
}public static void method_replace()
public static void method_trans()
;string s= new string(arr,1,3);
sop("s="+s);
string s1 = "zxcvbnm";
char chs = s1.tochararray();
for(int x=0; x
}public static void method_is()
public static void method_get()
public static void main(string args)
public static void sop(object obj)
}
傳智播客mysql分頁的實現 傳智播客 分頁
整理了一宿,終於找到了頭緒,在頭腦還算清醒時,整理下分頁的筆記.我這個分頁用的是oracle的資料庫.他在查詢時涉及到了乙個偽列.table名為 employees.建立bean物件employee.屬性如下 private int employee id private string first ...
傳智播客 servlet http協議
今天的老畢講的課程主要是關於 b s和 c s系統的一些底層通訊協議和 servlet 開發環境的搭建,也涉及到一些 servlet 開發的一些介面和繼承類。經過幾天的學習,逐漸形成自己的聽課節奏了,沒有前面兩天的壓抑了。自己總結,要學好程式設計,首先要有顆平常心,不要急功近利 其次,在學習的過程中...
傳智播客學習有感
來傳智播客學習幾個月了,學習的很差,為什麼呢,我曾經這麼回答過,如果乙個人曾經很輕鬆的賺過錢,然後某天他改行做程式設計了,那麼是一件很折磨人的事情,寫 絕對不是一件輕鬆的事情,很容易疲倦,也很容易煩躁不安,我在傳智播客學習了幾個月說真的學的很差,動手太差,只侷限於聽,導致的結果是做乙個簡單的html...