Ledger Nano X - The secure hardware wallet
SHARE
TWEET

Untitled

a guest Mar 29th, 2020 76 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Solution {
  2.   public static void main(String[] args) {
  3.       String S1 = "ABCD";   //println
  4.       //output char one by one from String S1 forward
  5.       //sample output
  6.       //A
  7.       //B
  8.       //C
  9.       //D
  10.       //output char one by one from Strign S1 backward
  11.       //sample output
  12.       //D
  13.       //C
  14.       //B
  15.       //A
  16.       String S2 = "EFGH";
  17.       //output char one by one from S1 and S2
  18.       //alternatively forward in the same line  (print)
  19.       //sample output: AEBFCGDH
  20.    
  21.       //output char one by one from S1 and S2
  22.       //alternatively backward in the same line  (print)
  23.       //sample output: HDGCFBEA
  24.       for (int i=0; i<S1.length(); i++){
  25.         System.out.println(S1.charAt(i));
  26.      }
  27.      for (int i=S1.length()-1; i>=0; i--){
  28.         System.out.println(S1.charAt(i));
  29.      }
  30.      for (int i=0; i<S1.length(); i++){
  31.         System.out.print(S1.charAt(i));
  32.         System.out.print(S2.charAt(i));
  33.      }  
  34.      System.out.println();
  35.      for (int i=S1.length()-1; i>=0; i--){
  36.         System.out.print(S2.charAt(i));
  37.         System.out.print(S1.charAt(i));
  38.      }
  39.      System.out.println();    
  40.       //Final
  41.       //output char one by one from S1 and S2
  42.       //S1  forward
  43.       //S2  backward
  44.       //alternatively in the same line  (print)
  45.       //sample output: AHBGCFDE
  46.      for (int i=0; i<S1.length(); i++){   //forward loop
  47.         System.out.print(S1.charAt(i));
  48.         System.out.print(S2.charAt(S1.length()-1-i));
  49.         //last index-1   can get backward index
  50.      }  
  51.        
  52.     }
  53. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top