Java中的char比较

时间:2015-11-10 17:45:51

标签: java char comparison

class Tryit {   
  public static void main(String args[])   
    throws java.io.IOException { 

    char ch, answer; 

    System.out.println("Please Enter a Secret Character for another user to guess."); 
    answer = (char) System.in.read(); 

    System.out.println("There is a Secret character for you...Can you guess it: \n"); 
    ch = (char) System.in.read(); // read a char from the keyboard 


    if(ch == answer) 

    {   
    System.out.println("** Right **"); 
    }
    else 
    {
    System.out.println("** Try Again **"); 
    }
  }   
}

我正在尝试比较ch和答案变量,但它不起作用,我犯了错误。帮助

1 个答案:

答案 0 :(得分:0)

使用扫描仪...很容易

然后只需与==进行比较,添加while循环

SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ':00:00 BETWEEN shift_start_time AND shift_end_time OR 16:00:00 BETWEEN shift_sta' at line 1 (SQL: select * from shifts where time_sheet_id = 13 AND user_id = 2 and 20:00:00 BETWEEN shift_start_time AND shift_end_time OR 16:00:00 BETWEEN shift_start_time AND shift_end_time OR 20:00:00 >= shift_start_time AND 16:00:00 <= shift_end_time)