Which of the following creates the string of the numbers from 1 to 1000 most efficiently?
a.
```
String s;
for (int i = 1; i <= 1000; i++)
s += i;
```
b.
```
StringBuilder sb = new StringBuilder(10);
for (int i = 1; i <= 1000; i++)
sb.append(i);
String s = new String(sb);
```
c.
```
StringBuilder sb = new StringBuilder(3000);
for (int i = 1; i <= 1000; i++)
sb.append(i);
String s = new String(sb);
```
d. All are equivalently efficient.
c.
```
StringBuilder sb = new StringBuilder(3000);
for (int i = 1; i <= 1000; i++)
sb.append(i);
String s = new String(sb);
```
You might also like to view...
An array is a very good data structure for storing a sequence whose size does not change.
Answer the following statement true (T) or false (F)
Which of the following is false?
a. JFrame is a lightweight component. b. JFrame is a subclass of Frame (which is a subclass of Window). c. JFrames have a title bar and a border. d. A JFrame window will look like all other windows displayed on that platform.
The Text Direction button rotates text in a cell 45 degrees each time you click the button.
Answer the following statement true (T) or false (F)
Today's computers use transistors and integrated circuits
Indicate whether the statement is true or false