java - How can I use a String in a different method? -
so i've got problem, i've got 4 methods, first method opens 2 files using scanner. second method reads 2 files using while loop on both files in order me make strings out of files content, while doing format strings have read file. third method meant match 2 strings first , second file don't know how strings third method. i've tried using instance variable won't work have strings in while loop , there more 1 string in each file well. sort of appreciated! i'll add problem match method.
my code:
public void read() { while (sta.hasnext()) { string ab = sta.next(); string bb = sta.next(); string cb = sta.next(); string a1 = ab.replace(",", " ").trim(); string b1 = bb.replace(",", " ").trim(); string c1 = cb.replace(",", " ").trim(); system.out.printf("%s\n%s\n%s\n", a1, b1, c1); } while (wr.hasnext()) { string p1 = wr.next(); string p2 = wr.next(); string m1 = p1.replace(",", " ").trim(); string m2 = p2.replace(",", " ").trim(); system.out.printf("%s\n%s\n", m1, m2); } } public void match(){ if (a1 == m1){ system.out.println("same"); } else { system.out.println("not same"); } }
thanks
Comments
Post a Comment