/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { int limit = 5 ; String input; int codePoint; for ( int i = 0 ; i < limit ; i++ ) { input = sc.next(); int[] codePoints = input.codePoints().toArray() ; if ( codePoints.length == 1 ) { codePoint = codePoints[ 0 ] ; } else { break; } } } }
H π· l l o
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, π·, l, l] for index 4 the input character is: o so we get the current result [H, π·, l, l, o] Done: [H, π·, l, l, o]