view raw
vineeth Prabhakaran vineeth Prabhakaran - 10 months ago 49
Java Question

Comparing character and String

I am writing a program to check wether the given sentence is a panagram or not, but I am not able to compare each character with the characters in a string.
Can anyone suggest me a method to get the desired output?

Scanner scan = new Scanner(;
String panagram = scan.nextLine();
String word = panagram.toLowerCase();
String a[] = { "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k",
"l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w",
"x", "y", "z" };
int count = 1;
System.out.println("a=" + a.length);
for (int i = 0; i < a.length; i++) {
for (int j = 0; j < word.length(); j++) {

if ((a[i]).equals(word.charAt(j)))// problem occurs here {



if (count == 26) {
} else {
System.out.println("not pangram");


You can use:


or change your a array from String[] to char[] and compare the character using the == operator.