Java Character find ASCII code

Question

We would like to find Integer Value of a Character.



public class Main{
    public static void main(String[] args){
        char[] cArr = {'A', 'B', 'C', 'a', 'b', 'c', '0', '1', '2', '$', '+', '/', ' '};

        for(char c : cArr){
            printResults(c);/*from w  w w  .  java 2 s. c  om*/
        }
    }
    // print results
    private static void printResults(char c){
       //your code here
    }
}



public class Main{
    public static void main(String[] args){
        char[] cArr = {'A', 'B', 'C', 'a', 'b', 'c', '0', '1', '2', '$', '+', '/', ' '};

        for(char c : cArr){
            printResults(c);
        }
    }
    // print results
    private static void printResults(char c){
        System.out.printf("The character %c has the value of %d\n", c, ((int) c));
    }
}



PreviousNext

Related