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
Post a Comment