Hello. One races, the user can enter 2 words, and the other races 3, and how to determine how many words he entered? Only str2 can be added, that is, for example, he entered one of the races:
first third
And another race:
first second third
Here for example my code:
Scanner g = new Scanner(System.in); String str1 = g.next(); String str2 = g.next(); String str3 = g.next(); if(str2.isEmpty()) { //у нас только есть str1 и str3 } else { //нам повезло, у нас есть три слова }
Only it does not work for me.