jeudi 2 février 2017

Java Scanner how to input string if function

I am very new in programming into Java.

My question is that i have a code(look below) and i want to compare them with if statment. An errors occur at line 9 (string test) and 11(if(test.quals) I completly do not have idea. I have made a code with int and it works perfcet, but that .... Could you please be able to help me?

class apples{       
    public static void main(String args[]){     
        Scanner input = new Scanner(System.in);     
        Scanner sc = new Scanner(System.in);    
        String test = sc.nextLine();        

        if (test.equals(YES)) {
            System.out.println("YES");  
        } else {        
            System.out.println("TIS IS ELS");   
        }       
    }

} 

Aucun commentaire:

Enregistrer un commentaire