i am trying to determine whether the string is pangram or not by using set in Java
I've tried the below code.Now the output is showing as not pangram but it should be a pangram. Pls tell me whats wrong in my solution
// Java Program to illustrate Pangram
import java.util.*;
public class GFG
{
public static boolean checkPangram (String str)
{
int index = 0,count=0;
char s[]=str.toCharArray();
Set<Character> hs= new HashSet<Character>();
for(index=0;index<str.length();index++)
{
hs.add(s[index]);
}
Iterator<Character> i=hs.iterator();
while(i.hasNext())
{
count++;
i.next();
}
if(count==26)
return true;
return false;
}
// Driver Code
public static void main(String[] args)
{
String str = "the quick brown fox jumps over the lazy dog";
if (checkPangram(str) == true)
System.out.print(str + " is a pangram.");
else
System.out.print(str+ " is not a pangram.");
}
}
output should be either true or false but I get no output