fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int limit = 5 ;
  13. StringBuilder sb = new StringBuilder() ;
  14.  
  15. Scanner sc = new Scanner(System.in);
  16.  
  17. String input;
  18. int codePoint;
  19.  
  20. for ( int i = 0 ; i < limit ; i++ ) {
  21. input = sc.next();
  22. int[] codePoints = input.codePoints().toArray() ;
  23. if ( codePoints.length == 1 ) {
  24. codePoint = codePoints[ 0 ] ;
  25. System.out.println( "for index " + i + " the input character is: " + Character.toString( codePoint ) );
  26. sb.appendCodePoint( codePoint );
  27. System.out.println("so we get the current result " + sb.toString() );
  28. } else {
  29. System.out.println( "Enter just one character." );
  30. break;
  31. }
  32. }
  33.  
  34. System.out.println( "Done: " + sb.toString() ) ;
  35. }
  36. }
Success #stdin #stdout 0.2s 54064KB
stdin
H
😷
l
l
o
stdout
for index 0 the input character is: H
so we get the current result H
for index 1 the input character is: 😷
so we get the current result H😷
for index 2 the input character is: l
so we get the current result H😷l
for index 3 the input character is: l
so we get the current result H😷ll
for index 4 the input character is: o
so we get the current result H😷llo
Done: H😷llo