Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class ComptaAsArray {
- //Hi ha 4 as.
- public static final char[] array = {'a','c','z','a','w','a','q','f','f','c','a'};
- public static void main(String[] args) {
- int comptador = 0;
- for (int i = 0; i < array.length; i++) {
- if (array[i] == 'a') {
- comptador++;
- }
- }
- System.out.println("Hi ha " + comptador + " a's.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment