0

how can i trace letter by letter? please in this code:

String str = "My Name Is Nada"; for(int x=0 ; x<str.length() ; x++){ // statement for tracing letter by letter😓 }

5th Sep 2017, 10:20 PM
Noush Rabah
Noush Rabah - avatar
10 Respostas
+ 5
Maybe you can try something like that: public void scroll(String text){ int delay = 50; ActionListener action = new ActionListener(){ int counter = text.length(); @Override public void actionPerformed(ActionEvent event){ if(counter == 0){ timer.stop(); }else{ System.out.print(text.substring(text.length()-counter, ((text.length()-counter)+1))); counter--; } } }; timer = new Timer(delay, action); timer.start(); }
5th Sep 2017, 10:35 PM
Dapper Mink
Dapper Mink - avatar
+ 5
But that doesn't wait before printing a letter
5th Sep 2017, 11:13 PM
Dapper Mink
Dapper Mink - avatar
+ 4
oh, my apologies then
5th Sep 2017, 10:30 PM
Dapper Mink
Dapper Mink - avatar
+ 3
You can't within SoloLearn because it executes all the code until the end first before showing you the console. Though you can by using a computer compiler such as Oracle
5th Sep 2017, 10:29 PM
Dapper Mink
Dapper Mink - avatar
+ 1
i found something easier: String str="My Name Is Nada"; for(int x=0 ; x<str.length() ; x++){ char c = str.charAt(x); }
5th Sep 2017, 11:05 PM
Noush Rabah
Noush Rabah - avatar
0
ues i know
5th Sep 2017, 10:29 PM
Noush Rabah
Noush Rabah - avatar
0
yes*
5th Sep 2017, 10:29 PM
Noush Rabah
Noush Rabah - avatar
0
i want the code only, im using net beans
5th Sep 2017, 10:29 PM
Noush Rabah
Noush Rabah - avatar
0
its okay bro
5th Sep 2017, 10:30 PM
Noush Rabah
Noush Rabah - avatar