0

int[] ram = new int[256];

    ram['A'] = 1;
    ram['b']=2;

    System.out.println(ram.length);
    System.out.println(ram['A']);
    System.out.println(ram[065]); //065 is ascii equivalent of 'A' - op is 0??

    for (int i : ram) {

        if(ram[i]>0)
        System.out.println(ram[i]);

    }




}

How is an array accepting character as index? Usually it will be numbers .. Can someone explain the above concept?

3
  • @TimBiegeleisen Nothing to do with it. No parsing here. Commented Feb 9, 2020 at 4:33
  • A char has an integral value, and can be promoted to int in the usual way. No mystery. Commented Feb 9, 2020 at 4:34
  • Hi, For more information please check this link : javatpoint.com/java-char-to-int Commented Feb 9, 2020 at 4:53

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.