-1
我在我的代碼的這一行中收到錯誤。二元運算符'>'的不良操作數類型
if (age < 17) {
System.out.println("You are a adult");
的錯誤是錯誤的操作數類型的二元運算符「>」
這是我的全部代碼
package transition.work;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author New
*/
public class TransitionWork {
/**
* @param args the command line arguments
* @throws java.io.IOException
*/
public static void main(String[] args) throws IOException {
System.out.println("Hello, what is your name?");
InputStreamReader inputStreamReader = new InputStreamReader(System.in);
BufferedReader reader = new BufferedReader(inputStreamReader);
System.out.println("Type name:");
String name = reader.readLine();
System.out.println("Hello "+name+", How old are you?");
String age;
age = reader.readLine();
if (age < 17) {
System.out.println("You are a adult");
}
}
}
預先感謝您的幫助! :)