Skip to content

Instantly share code, notes, and snippets.

@Yurlov
Created June 17, 2016 11:51
Show Gist options
  • Save Yurlov/bef8e59d6e5ec7cf45727f9442da9fc0 to your computer and use it in GitHub Desktop.
Save Yurlov/bef8e59d6e5ec7cf45727f9442da9fc0 to your computer and use it in GitHub Desktop.
public class ArrayPositivesCounter {
public static void main(String[] args) {
int [] array ={-3, 0, -1, 3, -2, 5};
int countPositiveArray = countPositives(array);
System.out.println("Positive numbers in array: "+countPositiveArray);
}
private static int countPositives(int[]array){
int sumPostv = 0;
for(int i = 0;i<array.length;i++){
if (array[i]>0) {
sumPostv += 1;
}
}
return sumPostv;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment