When I execute the following:
static void Append() {
StringBuilder sb = new StringBuilder();
System.out.print("How many words do you want to append? ");
int n = input.nextInt();
System.out.println("Please type the words you want to append: ");
for (int c = 1; c <= n; c++) {
String str = input.nextLine();
sb.append(str);
System.out.print(" ");
}
System.out.print(sb);
}
Let's say if I put 3, then the computer lets me type only 2 words..
This is the output:
How many words do you want to append? 3
Please type the words you want to append:
I
am
Iam
Also, why is there a space before the words? the print function is after the input function. So shouldn't it be the opposite?