上篇整理了下后面准备更系统化写的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());
}复制代码
本文做者:毕玄 小程序
原文连接bash
本文来自云栖社区合做伙伴“HelloJava”,如需转载请联系原做者。并发