Demlo number ( Square of 11. . .1 ) | Java program to print DemloNumber ; To return demlo number . This function assumes that the length of str is smaller than 10. ; Add numbers to res upto size of str and then add number reverse to it ; Driver program to test printDemlo ( )
public class Main { static String printDemlo ( String str ) { int len = str . length ( ) ; String res = " " ; for ( int i = 1 ; i <= len ; i ++ ) res += Integer . toString ( i ) ; for ( int i = len - 1 ; i >= 1 ; i -- ) res += Integer . toString ( i ) ; return res ; } public static void main ( String [ ] args ) { String str = "111111" ; System . out . println ( printDemlo ( str ) ) ; } }