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

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

如何實現(xiàn)插入的順序與顯示的順序一致

如何實現(xiàn)插入的順序與顯示的順序一致

car 2017-10-11 23:34:57
代碼運行總是顯示順序與插入順序相反public?class?BusLine?{ int?id; String?name; BusLine?next; public?BusLine(int?id,?String?name)?{ this.id?=?id; this.name?=?name; } public?void?displayBusLine()?{ System.out.println(id?+?"->"?+?name); } }public?class?BusLineList?{ private?BusLine?first; public?BusLineList()?{ first?=?null; } public?void?insertFirst(int?id,?String?name)?{ BusLine?newBusLine?=?new?BusLine(id,?name); newBusLine.next?=?first; first?=?newBusLine; } public?void?displayList()?{ BusLine?current?=?first; while?(current?!=?null)?{ current.displayBusLine(); current?=?current.next; } } public?BusLine?delete(String?name)?{ BusLine?current?=?first; BusLine?previous?=?first; if?(current?!=?null?&&?name?!=?null)?{ while?(current.next?!=?null?&&?!name.equals(current.name))?{ previous?=?current; current?=?current.next; } } if?(current?==?first) first?=?first.next; else?if?(previous?!=?null)?{ previous.next?=?current.next; } return?current; } public?BusLine?find(String?name)?{ BusLine?current?=?first; if?(current?!=?null?&&?name?!=?null)?{ while?(current.next?!=?null?&&?!name.equals(current.name))?{ current?=?current.next; } } return?current; } }public?class?BusLineApp?{ public?static?void?main(String[]?args)?{ BusLineList?busLineList?=?new?BusLineList(); int?i?=?0; busLineList.insertFirst(++i,?"市光路"); busLineList.insertFirst(++i,?"嫩江路"); busLineList.insertFirst(++i,?"翔殷路"); busLineList.insertFirst(++i,?"黃興公園"); busLineList.delete("翔殷路"); busLineList.displayList(); BusLine?currentBusLine?=?busLineList.find("黃興公園"); System.out.println(currentBusLine.id); System.out.println(currentBusLine.name); } }
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 1201 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號

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