上篇整理了下後面準備更系統化寫的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);
}less
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());
}debug
原文連接 本文爲雲棲社區原創內容,未經容許不得轉載。