Display one character at a time.
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) + "Letter= " + s.charAt(i));
}
for(int i = ( s.length() - 1); i >=0 ;i--){
System.out.println( (i + 1) + "Letter= " + s.charAt(i));
}
}
}
Recommended Posts