Created
December 17, 2011 08:03
-
-
Save shekhargulati/1489623 to your computer and use it in GitHub Desktop.
A Java Puzzler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ans is 8 coz of a typo at if