上篇整理了下後面準備更系統化寫的Java編程進階的思路,若是僅看裏面的詞,不少同窗會以爲都懂,但我真心以爲沒有多少人是真懂的,因此簡單的想了一些題目,感興趣的同窗們能夠來作作看,看看本身的Java編程水平怎麼樣。數據庫
懶得去作小程序了,因此你們就直接回復你的答案吧,我會來一一點評下,友情提醒下,有些題目有點坑。編程
private void callDecode(...) { List<Object> results = new ArrayList<Object>(); while (cumulation.readable()) { int oldReaderIndex = cumulation.readerIndex(); Object frame = decode(context, channel, cumulation); if (frame == null) { if (oldReaderIndex == cumulation.readerIndex()) break; else continue; } else if (oldReaderIndex == cumulation.readerIndex()) { throw new IllegalStateException( "....."); } results.add(frame); } if(results.size() > 0) fireMessageReceived(context, remoteAddress, results); }
private void callDecode(...) { int oldReaderIndex = cumulation.readerIndex(); Object frame = decode(context, channel, cumulation); if (frame != null) fireMessageReceived(context, remoteAddress, frame); }
List getUsers(String[] userIds){ // 從數據庫查找符合userIds的user記錄 // 將返回的記錄組裝爲User對象,放入List並返回 }
private static final boolean isLoggerDebugEnabled = log.isDebugEnabled(); public void xx(User user){ if(isLoggerDebugEnabled){ log.debug("enter xx method, user id is: " + user.getId()); } }
public void xx(User user){ log.debug("enter xx method, user id is: " + user.getId()); }
本文做者:畢玄 小程序
原文連接併發
本文來自雲棲社區合做夥伴「HelloJava」,如需轉載請聯繫原做者。less