Java code to save a variable to a a text file
本问题已经有最佳答案,请猛点这里访问。
我需要代码将像
到目前为止我的代码是:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | package battleships.startmenu; import java.util.Scanner; public class Startmenu { public static void main(String[] args) { System.out.print("Hello! Please enter your first name:"); Scanner reader = new Scanner(System.in); String a; String b; a=reader.next(); System.out.print("Enter your second name:"); b=reader.next(); System.out.println("Hello" + a+"" + b +"!"); System.out.println("\tHello"); String name; name = a + b; } } |
我希望变量名称打印到名为name.txt的文档中
创造一个作家
1 |
写一条线
1 | writer.println(name); |
关闭作家
1 | writer.close(); |
将
1 |