How to add all the ABC letters to char array in Java

1 Answer

0 votes
package javaapplication1;

import java.io.IOException;

public class JavaApplication1 {

    public static void main(String[] args) throws IOException {

        char[] arr = new char[26];
        int i = 0;

        for (char ch = 'a'; ch <= 'z'; ch++) {
            arr[i++] = ch;
        }

        for (i = 0; i < arr.length; i++) {
            System.err.print(arr[i]);
        }
    }
}


/*

run:
                   
abcdefghijklmnopqrstuvwxyz
          
 */

 



answered Dec 19, 2016 by avibootz
edited Jan 10, 2017 by avibootz

Related questions

2 answers 237 views
1 answer 210 views
1 answer 209 views
1 answer 231 views
1 answer 233 views
1 answer 217 views
...