I have two classes. And I want the code in the for loop in the class below to run twice, however when I sent int i = 0 and the condition to i < 2, it only seemed to run once. As you can see I've had to set it to i < 3 to get it to run just twice.
import java.util.Scanner;
public class LPrint {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.println("sender: ");
String a = input.next();
System.out.println("recepiant: ");
String b = input.next();
Letter one = new Letter(a, b);
System.out.println("letter: ");
for (int i = 0; i < 3; i++) {
one.body = one.body.concat(input.nextLine() + "\n");
}
System.out.print(one.getLetter());
}
}
In the other class, the String body = "", and it is only used in String result = ("to " + recepiant + ":\n").concat(body + "\n").concat("regards,\n").concat(sender);