What will be the result of attempting to compile and run the following program?.
public class Main { public static void main(String[] args) { StringBuilder sb = new StringBuilder("have a nice day"); sb.setLength(6); System.out.println(sb); } }
Select the one correct answer.
setLength()
in the StringBuilder class.println()
method.(e)
The program will compile without errors and will print have a when run.
The contents of the string buffer are truncated down to 6 characters.