desislava_topuzakova

05. Character Sequence

Jun 26th, 2021
1,459
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.95 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class StreamOfLetters {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         String text = scanner.nextLine();
  7.  
  8.         //за всяка една позиция от 0 до последната
  9.         //повтарям: взимам символа на тази позиция + печатам
  10.  
  11.         //начална стойност: 0 (първа позиция)
  12.         //крайна стойност:  дължина - 1 (последната позиция)
  13.         //повтарям: взимам символа на тази позиция + печатам
  14.         //промяна: преминавам към следващата позиция (+1)
  15.         for (int position = 0; position <= text.length() - 1; position++) {
  16.             char currentSymbol = text.charAt(position);
  17.             System.out.println(currentSymbol);
  18.         }
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment