for loop to while loop

后端 未结 4 1000
北海茫月
北海茫月 2021-01-17 01:53

I am using a for loop to print the backwards alphabet in uppercase but I would like to know how to do the same thing with a while loop, which I am

4条回答
  •  太阳男子
    2021-01-17 02:24

    x = alphabet.length() - 1;
    while( x > -1 )
        {
            System.out.print(  alphabet.charAt( x ));  
            System.out.print( alphabet.toUpperCase() );
            x--;
        }
    

提交回复
热议问题