1
LẬP TRINH HƯỚ NG ĐÔ
́
I TƯỢNG TRONG JAVA
phần 5
LỚ P STRING VÀ NUMBER
I.
.
.
?
,
,
:
StringBuffer,
,
,
. StringBuffer
.
V d :
2
StringBuffer dest = new StringBuffer(len);
for (i = (len - 1); i >= 0; i )
dest.append(source.charAt(i));
return dest.toString();
}
}
1. Lơ
́
p String
To mt đi tưng
.
ba
,
byte b[] = {65, 66, 67, 68, 69, 70};
String s1 = new String(b); // K
DEF
String s2 = new String(b,2,3); // K
3
String s3 =
(c); // Kh
String s4 = new String(c,2,3); //
() v= = .
. = = so s2
.
String s1
String s2 = new String(s1); // t 2 1,
//
)
character,
from ( )
int lastIndexOf(int character, int from)
- int indexOf(String string) : (c
) string
int lastIndexOf(String string)
- int indexOf(String string, int from) : (c
)
string,
from ( )
int lastIndexOf(String string, int from)
- String subString(int startIndex, int endIndex) :
- String toUpperCase() :
String upper = s.toUpperCase();
- Ton tư
̉
+ : ,
,
String s1 = "two";
System.out.println("one" + s1 + "three");
System.out.println("Word v. " + 9+7);
V
,
sang StringBuffer
public class ReverseString {
5
public static String reverse(String source) {
int i, len = source.length();
for (i = (len - 1); i >= 0; i )
dest = dest + source.charAt(i);
return dest;
}
}
- static String valueOf(object/var x) :
, tr
V d :
- void setCharAt(int index, char ch) :
,
- StringBuffer append(object/var x) :
.
int a = 20;
StringBuffer sb = new StringBuffer(40);
- StringBuffer deleteCharAt(int index) :
- StringBuffer subString(int startIndex, int endIndex) :
-1,
- StringBuffer replace(int startIndex, int endIndex, String str) :
dex-1
.lang.String and java .lang.