我在这行代码中遇到错误。
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");
}
}
}
预先感谢您的帮助!:)