精華區beta java 關於我們 聯絡資訊
The code fragment below should print: OrthForms: movie PartOfSpeech: n Synonyms: feature film flick Definition: action on continuous film but it prints: OrthForms: n PartOfSpeech: movie Synonyms: feature film flick Definition: action on continuous film Find and fix the bug in this code: String line = "movie n 3 feature film flick action on continuous film"; Scanner lineScan = new Scanner(line); String word = "", pos = "", synonyms = "", definition = ""; int numSynonyms = 0; LexUnit lex; word = lineScan.next(); pos = lineScan.next(); numSynonyms = lineScan.nextInt(); lex = new LexUnit(pos, word); for (int i=0; i < numSynonyms; i++) { lex.addSynonym(lineScan.next()); } lex.setDefinition(lineScan.nextLine()); System.out.println(lex); 以上是考古題裡的一道題, 不太懂 LexUnit lex; 做了些什麼 為何 movie 和 n PRINT出來的位置會相反 希望有人可以幫忙註解說明一下... 先謝過 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 134.2.251.34