\n won't work, not going to a new line

后端 未结 5 792
隐瞒了意图╮
隐瞒了意图╮ 2021-01-14 02:48

I\'m creating a small program that saves a int value into a text file, saves it, and loads it when you start the program again. Now, I need 3 more booleans to be stored in t

5条回答
  •  长发绾君心
    2021-01-14 03:34

    No problem here:

    System.out.format ("first: %s%s", "" + x + "\n", "" + y + "\n");
    

    While I would prefere, to integrate the \n into the format String, not the values:

    System.out.format ("second: %s\n%s\n", x, y);
    

    Using Formatter.format works the same.

提交回复
热议问题