How do I store these printed letters into an array?

后端 未结 2 1015
名媛妹妹
名媛妹妹 2021-01-26 12:45

Right now this program prints out the alphabet (a-z) however I want to take those letters and store each one in the array called leta, how do i do that?

public c         


        
2条回答
  •  面向向阳花
    2021-01-26 13:08

     public class Arrayofhope {
     public static void main (String[]args) {
     char []leta = new char[26];
     char letter = (char)65;
     char lettter=(char)90;
     for (int i = letter,j=0;i<=lettter;i++,j++ ) {
    
    let[j] = (char)i;
    

    // If you don't want new variable you can do like below

    let[i-65] = (char) i;
    
    
    System.out.print((char)i);
    
    }
    }
    }
    

提交回复
热议问题