Fuuuuuuck | Sololearn: Learn to code for FREE!
Neuer Kurs! Jeder Programmierer sollte generative KI lernen!
Kostenlose Lektion ausprobieren
4 Antworten
+ 3
You had if instead of for, lenght instead of length, length is a method so it needs (), and it returns the actual count of character so you need to -1.
25th Oct 2017, 2:39 PM
John Wells
John Wells - avatar
+ 2
thanks
25th Oct 2017, 2:44 PM
Spinoza
Spinoza - avatar
+ 1
i want to give the program a string like; MNB and the program give me back BNM
25th Oct 2017, 2:30 PM
Spinoza
Spinoza - avatar
+ 1
import java.util.Scanner; public class Program { public static void main(String[] args) { String mm = new Scanner(System.in).nextLine(); for (int a = mm.length()-1;a !=-1;a--) { System.out.println(mm.charAt(a)); } } }
25th Oct 2017, 2:35 PM
John Wells
John Wells - avatar