StringBuilder & Chatacter

StringBuilder

append(String/StringBuilder/int)

StringBuilder sb = new StringBuilder("Hello");
sb.append(" World");      // "Hello World"
sb.append(123);           // "Hello World123"
sb.append('\n');          // append newline

insert(int,String)

sb.insert(5, " Java");    //insert string at specified index;existing char at and beyond the index will shifted to right;
// result: "Hello Java World123"

delete(int start ,int end)

delete char from start to end-1

sb.delete(5, 10);         
// result: "Hello World123"

deleteCharAt(int index)

sb.deleteCharAt(5);       //delete character at specify index(' ')
// result: "HelloWorld123"

replace(int start,int end,String s)

sb.replace(5, 10, "Java"); //replace char which's index from start to end-1  with "java"
// result: "HelloJava123"

reverse()

reverse the String

charAt(int index)

char c = sb.charAt(6);    // return the Character with specify index

indexOf(String s)

int index = sb.indexOf("Java"); // return the index of first occurence of the substring

lastindexOf(String s)

int index = sb.indexOf("Java"); // return the index of last occurence of the substring

substring(int index)

String sub = sb.substring(6); // return substring from index to end 
//result:"Java123"

Character

judge

Character.isDigit(char)

Determine it’s weather a digit.

isLetter(char)

Determine it’s weather a letter.

isLetterOrDigit(char)

Determine it’s weather it’s a letter or digit

isLowerCase(char)

Determine it’s weather it’s a lowercase Character

isUpperCase(char)

Determine it’s weather it’s a uppercase character.

isWhitespace(char)

Determine it’s weather a blank symbol

isISOControl(char)

Determine it’s weather a ISO control symbol

convert

toLowerCase(char)

convert to lowercase character

toUpperCase(char)

convert to Uppercase Character

digit(char ch,int radix)

convert to a number in the specified base

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值