+ 1

Need an output

i need the output: 1 R 2 A 3 Y 4 H 5 A 6 N +--------+-----+---- How to code with loop and breaking the Rayhan String letter to later and print with loop

28th Feb 2019, 4:08 AM
Ferdous Rayhan
Ferdous Rayhan - avatar
2 Antworten
+ 15
● run loop from i=0 to i=(yourName.length()-1), in each iteration do println ((i+1)+" "+yourName.charAt(i));
28th Feb 2019, 6:40 AM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 11
Hint : use length() and charAt() method length() method in String class provid a length of String and return integer value and ( you can stroe the value in int) For Example : String a="Rayhan"; System.out.print(a.length()); Output : 6 becz in your name have 6 letters charAt() method in String class provid a functionality fund character in given position and return character value and you can store in char data type. For Example : String a =''Rayhan"; System.out.println(a.charAt(2)); Output : y becz postion of R is 0;
28th Feb 2019, 6:40 AM
Sumit Programmer😎😎
Sumit Programmer😎😎 - avatar