Я новичок в Java. Я читаю книгу Введение в программирование на Java v7 и нашел проблему с кодом, как это:TextIO.getln() не может вводить данные?
public class CreateProfile {
public static void main(String[] args) {
// TODO Auto-generated method stub
String name;
String email;
double salary;
String favColor;
TextIO.putln("Good Afternoon! This program will create");
TextIO.putln("your profile file, if you will just answer");
TextIO.putln("a few simple questions.");
TextIO.putln();
/* Gather responses from the users. */
TextIO.put("What is your name? ");
name = TextIO.getln();
TextIO.put("What is your email address? ");
email = TextIO.getln();
TextIO.put("what is your salary income? ");
salary = TextIO.getDouble();
TextIO.putln();
TextIO.put("What is your favorite color? ");
favColor = TextIO.getln();
/* Write the user's information to the file named profile.txt. */
TextIO.writeFile("profile.txt"); //subsequent output goes to file
TextIO.putln("Name: " + name);
TextIO.putln("Email: " + email);
TextIO.putln("Favorite Color: " + favColor);
TextIO.putf("Yearly Income: %1.2f%n", salary);
/* Print a final message to standard output. */
TextIO.writeStandardOutput();
TextIO.putln("Thank you. Your profile has been written to profile.txt.");
}
}
консоль не просит меня ввести любимый цвет но перейти непосредственно к написанию процесса файла.
Как когда я ставлю входной заявление favColor до зарплаты, там, кажется, не было никаких проблем:
Может кто-нибудь, пожалуйста, объясните мне, почему?
Вы злоупотребляете тегом javers, пожалуйста, удалите его (оставьте только java) –
Привет, Что такое тег javers? Я считаю, что я использовал только Java с классом TextIO? – Rubit
А я думаю, я знаю, о чем ты говоришь. Спасибо. – Rubit