精華區beta java 關於我們 聯絡資訊
之前在做考古題, 有一題, 不了解發生了什麼事, 懇請先進指點... Consider the familiar LexUnit class included at the end of the exam. 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); 為何 n movie 輸出順序不對? -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 141.70.6.18