Skip to content

Instantly share code, notes, and snippets.

@shekhargulati
Created December 17, 2011 08:03
Show Gist options
  • Save shekhargulati/1489623 to your computer and use it in GitHub Desktop.
Save shekhargulati/1489623 to your computer and use it in GitHub Desktop.
A Java Puzzler
public static void main(String[] args) throws Exception {
List<String> words = Arrays.asList("hello","hi","hiya","hello world","bye","java","c++","python");
int count = 0;
for (String word : words) {
if (word.startsWith("h"));{
count++;
}
}
System.out.println("Count " + count);
}
@samarthrastogi
Copy link

ans is 8 coz of a typo at if

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment