这是android版本号:
import java.io.Serializable; import java.io.UnsupportedEncodingException; import java.nio.ByteBuffer; import java.nio.CharBuffer; import java.nio.charset.Charset; import java.nio.charset.Charsets; import java.util.Arrays; import java.util.Comparator; import java.util.Formatter; import java.util.Locale; import java.util.regex.Pattern; import libcore.util.EmptyArray;//这个貌似是google自己的api类库
import java.io.ObjectStreamField; import java.io.UnsupportedEncodingException; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Comparator; import java.util.Formatter; import java.util.Locale; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.regex.PatternSyntaxException;
public int compareToIgnoreCase(String string) {
int o1 = offset, o2 = string.offset, result;
int end = offset + (count < string.count ? count : string.count);
char c1, c2;
char[] target = string.value;
while (o1 < end) {
if ((c1 = value[o1++]) == (c2 = target[o2++])) {
continue;
}
c1 = foldCase(c1);
c2 = foldCase(c2);
if ((result = c1 - c2) != 0) {
return result;
}
}
return count - string.count;
}
public int compareToIgnoreCase(String str) {
return CASE_INSENSITIVE_ORDER.compare(this, str);
}
public native char charAt(int index); public native int compareTo(String string); public native boolean equals(Object object); private native int fastIndexOf(int c, int start); public native boolean isEmpty(); public native int length();
public char charAt(int index) {
if ((index < 0) || (index >= value.length)) {
throw new StringIndexOutOfBoundsException(index);
}
return value[index];
}
public int compareTo(String anotherString) {
int len1 = value.length;
int len2 = anotherString.value.length;
int lim = Math.min(len1, len2);
char v1[] = value;
char v2[] = anotherString.value;
int k = 0;
while (k < lim) {
char c1 = v1[k];
char c2 = v2[k];
if (c1 != c2) {
return c1 - c2;
}
k++;
}
return len1 - len2;
}
public boolean equals(Object anObject) {
if (this == anObject) {
return true;
}
if (anObject instanceof String) {
String anotherString = (String) anObject;
int n = value.length;
if (n == anotherString.value.length) {
char v1[] = value;
char v2[] = anotherString.value;
int i = 0;
while (n-- != 0) {
if (v1[i] != v2[i])
return false;
i++;
}
return true;
}
}
return false;
}
版权声明:本文博主原创文章,博客,未经同意不得转载。
javaS的tring和androidS的tring区别是什么?
原文:http://www.cnblogs.com/gcczhongduan/p/4803619.html