I'm trying to initialize a StringBuilder with "". These are 2 samples, the first one doesn't work while the second one works. Can anyone explain a bit more? Is this because StingBuilder is an object?
for (StringBuilder element : sb){
element = new StringBuilder("");
} // this solution doesn't work, print sb[0] = null
for(int i=0; i<sb.length; i++){
sb[i] = new StringBuilder("");
}
I'm expecting both would work.