samedi 29 avril 2017

Read each individual word in string per 'if'

Hi is there a way to make Java read each individual word per 'if' in string? I will try my best to explain this...

public class test{
    public static void main(String[] args){
        String sentence = "testing1 testing2 testing3 testing4"

        //Scan first word \/ 
        if(sentence.equals("testing1"){
            //scan second word \/
            if(sentence.equals("testing2"){
                //scan third word \/
                if(sentence.equals("testing3"){
                    System.out.println("Works good!")
                }
            }
        }
    }
}   

If you can help me I would really appreciate it. ~Keion Vergara

Aucun commentaire:

Enregistrer un commentaire