서브 시퀀스 (a, b) .toString() 이 하위 문자열 (a, b)보다 빠릅니다. 내가 인 경우 모든 하위 시퀀스를 하위 문자열으로 변환하면 항상 % 7까지 느려집니다. 왜 그렇게됩니까? 다음은 제 코드입니다.subsequence (a, b) .toString()이 하위 문자열 (a, b)보다 빠른 이유는 무엇입니까?
private static String filterStr(String s)
{
for(int a = 0; a < s.length(); a++)
{
int c = s.charAt(a);
if(((c < 65) || ((c >90) &&(c < 97)) || (c > 122)))
{
if(c!=34 && c!=96 && c!=39)// tırnak değillerse
{
String temp = s.substring(0,a);
temp+= s.subSequence(a+1,s.length());
s = temp;
a--;
}
else
{
if(a !=0) // if not at the beginning
{
if(a == s.length()-1)
s = s.subSequence(0,s.length()-1).toString();
else
s = s.subSequence(0,s.length()-2).toString();
}
else
s = s.subSequence(1,s.length()).toString();
}
}
if(c >= 65 && c <= 90) // convert to lower case first character.
{
String temp = s.substring(1,s.length());
c+=32;
s = (char)c + temp;
}
}
return s;
}
Javadoc은 무엇이라고 말합니까? 'String' 소스 코드를 보셨습니까? – Kayaman