I want to call the String "word" that I declared in my main method
for (int i = 0; i<n; i++){
System.out.println("Type the required word list");
String word = sc.nextLine();
ncount++;
}
and use it inside the method "countTest"
public static boolean countTest( ) {
char beginning = word.charAt(0);
char end = word.charAt(word.length()-1);
if ((beginning >= 65 && beginning <= 90) && end >= 48 && end <= 57 && word.toLowerCase().contains("ok"))
return true;
}
I'm unfamiliar with methods and how they work, the fact that the string is inside the for loop throws me off even more and I cant think of a way to call it.
Current Error Message:
Exception in thread "main" java.lang.Error: Unresolved compilation problems: word cannot be resolved