java - Make Multiple Strings with For Loop -


so have text file reader reads in each string come in.

string r1name = filescanner.nextline(); string r1url = filescanner.nextline(); string r2 = filescanner.nextline(); string r2name = filescanner.nextline(); string r2url = filescanner.nextline(); string r3 = filescanner.nextline(); string r3name = filescanner.nextline(); string r3url = filescanner.nextline(); 

etc.

how can have creates simple loop number 1-7 same thing less code?

for(int i=0; i<8; i++){              string r(i) = filescanner.nextline();             string r(i)url=filescanner.nextline();     } 

trying no luck

you can use array:

string[] r = new string[8]; string[] rurl = new string[8];  for(int = 0; < 8; i++) {     r[i] = filescanner.nextline();     rurl[i] = filescanner.nextline(); } 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -