joseleonweb

Untitled

Aug 26th, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.37 KB | None | 0 0
  1. public class ComptaAsArray {
  2.  
  3.   //Hi ha 4 as.
  4.   public static final char[] array = {'a','c','z','a','w','a','q','f','f','c','a'};
  5.  
  6.   public static void main(String[] args) {
  7.     int comptador = 0;
  8.     for (int i = 0; i < array.length; i++) {
  9.       if (array[i] == 'a') {
  10.         comptador++;
  11.       }
  12.     }
  13.     System.out.println("Hi ha " + comptador + " a's.");
  14.   }
  15. }
Advertisement
Add Comment
Please, Sign In to add comment