第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

樹集未添加所有對象

樹集未添加所有對象

慕工程0101907 2021-10-20 10:58:21
我正在為越南語寫字典,但我的 Treeset 只添加了 1 個對象。我一直在尋找 2 天,但我無法弄清楚如何。希望你們幫助我。public class Word implements Comparable<Word> {private static String word_target, word_explain;public static void setWord_target(String word_target) {    Word.word_target = word_target;}public static void setWord_explain(String word_explain) {    Word.word_explain = word_explain;}public String getWord_explain() {    return word_explain;}public String getWord_target() {    return word_target;}@Overridepublic int compareTo(Word word) {    return this.getWord_target().compareTo(word.getWord_target());}}public class Dictionary {private TreeSet<Word> words = new TreeSet<Word>();public TreeSet<Word> getWords() {    return words;}}public class DictionaryManagement {static Scanner reader = new Scanner(System.in);public static int numbers;public static void insertFromCommandline(Dictionary dic) {    numbers = reader.nextInt();    reader.nextLine();    for (int i = 0; i < numbers; i++) {        Word putInWord = new Word();        String en_word, vn_word;        System.out.print("English Word: ");        en_word = reader.nextLine();        putInWord.setWord_target(en_word);        System.out.print("VietNameses Word: ");        vn_word = reader.nextLine();        putInWord.setWord_explain(vn_word);        dic.getWords().add(putInWord);    }}}public class DictionaryCommandline {private static int num = 1;public static Dictionary showWord = new Dictionary();public static void showAllWords() {    System.out.println("No      |English            |Vietnamese");    for (Word wr : showWord.getWords()) {        System.out.println( num++ + "       |" + wr.getWord_target() + "             |" +  wr.getWord_explain());    }}例子:輸入:2英文單詞:房子越南語詞:義芽英文單詞:姓名越南語詞:十- 實際輸出:沒有英語越南1名十- 預期輸出:沒有英語越南1 房子 ngoi nha2名十
查看完整描述

1 回答

  • 1 回答
  • 0 關注
  • 113 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號