1
StringBuilder builder = new StringBuilder();
builder.setLength(10);
builder.append("d");
System.out.println(builder.length() + "\t" + builder.toString() + "\t" + builder.indexOf("d"));
11
문제 :
Why indexOf() doesn't return anything.
내 이해 :
As per my understanding, it should return 10, since StringBuilder is counting the "d" as part of its length in length().
But in case if "d" is not part of string hold by StringBuilder then, it should return -1 and length should be 10.
+1 .. :) 그것에 –
을 날 이길하지만 인쇄 문에, 나는'같이 IndexOf를()', 그리고 내가 반환 값을 받고 있지 않다. 나는 코드를 다시 실행하고 11 개만 출력한다. – guptakvgaurav
@GauravGupta - 내 대답에 편집을 확인하십시오! :) – SudoRahul