in below code, meaning of following line?
m.put(alpha, l=new arraylist<string>()); code (for finding anagrams):
try { scanner s = new scanner(new file(args[0])); while (s.hasnext()) { string word = s.next(); string alpha = alphabetize(word); list<string> l = m.get(alpha); if (l == null) m.put(alpha, l=new arraylist<string>()); l.add(word); } } catch (ioexception e) { system.err.println(e); system.exit(1); }
the part
m.put(alpha, l=new arraylist<string>()); could written as
l=new arraylist<string>(); m.put(alpha, l); an assignment returns assigned value, why code working.
Comments
Post a Comment