+ 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
2 Antworten
+ 15
● run loop from i=0 to i=(yourName.length()-1), in each iteration do println ((i+1)+" "+yourName.charAt(i));
+ 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;