Just wondering, is it not allowed to use Starts/EndsWith functions with Scanner? I'm trying to make a simple program where some elements from the set of array that I will provide will be printed out using those functions. But obviously there is an error that I don't know where it is. Please help
import java.util.Scanner;
public class test {
public static void main (String[] args)
{
Scanner input = new Scanner(System.in);
String[] animals = new String[5];
System.out.println("Enter animal type");
for (String j : animals){
if (j.startsWith("do"))
System.out.println(j);
}
}
}