int num;
num = in.nextInt();
String array[] = new String[num];
for (int i = 0; i < num; i++) {
array[i] = in.next();
if (array[i].equals("hey guys"))
System.out.println("hey guys");
else
System.out.println("buzz");
}
This is the code i tried. When i remove the space in "hey guys", it works allright but otherwise it doesn't.
You can use contains() method from String class to check if the string has spaces in it.But from what I understood,you are facing the issue while reading the string with spaces.You should read in using in.nextLine()