LoginSignup
0
0

More than 3 years have passed since last update.

文字列を一文字ずつ表示[メモ書き]

Last updated at Posted at 2020-10-10

1文字ずつ表示させる。

demojava/demo8/Demo8.java
package demojava.demo8;

public class Demo8 {
    public static void main(String[] args) {

        String s = "TENET";
        for(int i = 0 ; i < s.length();i++){
            System.out.println( (i + 1) + "文字目 = " + s.charAt(i));
        }
        for(int i = ( s.length() - 1); i >=0 ;i--){
            System.out.println( (i + 1) + "文字目 = " + s.charAt(i));
        }

    }

}

2020-10-10_21-19-47.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0