逍遥骑士

天行健,君子以自强不息

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年10月16日

摘要: Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz".For numbers which are multiples of both three and five print "FizzBuzz".Additionally, instead of printing &quo 阅读全文
posted @ 2013-10-16 23:26 逍遥骑士 阅读(501) 评论(0) 推荐(0) 编辑

摘要: 在jstl中,如果返回的字符串中含有换行符(\n),浏览器会将它渲染为空格(" "),但jsp中显然无法使用空格将其替换或分割, 使用: ${fn:split(entityBody.value.remark,'\n') } eclipse报错, 而使用: ${fn:split(entityBody.value.remark,'\\n') } 控制台报jsp错。猜测jstl不能直接书写java当中的转义字符。 google之后发现,先绑定变量到request中,然后从其中取值,可以解决问题 //then${fn:split(entityBody 阅读全文
posted @ 2013-10-16 17:11 逍遥骑士 阅读(1624) 评论(0) 推荐(0) 编辑

摘要: Given a regular expression with characters a-z, ' * ', ' . 'the task was to find if that string could match another string with characters from: a-zwhere ' * ' can delete the character before it, and ' . ' could match whatever character. ' * ' always appear af 阅读全文
posted @ 2013-10-16 00:23 逍遥骑士 阅读(314) 评论(0) 推荐(0) 编辑

2013年10月13日

摘要: I need a function that takes the name of the movie to look up andthe width of the letter grid, and computes the key presses thatwill enter that string on the DVR grid. The output should be astring, with "u", "d", "l", "r", and "!" corresponding to up 阅读全文
posted @ 2013-10-13 23:00 逍遥骑士 阅读(178) 评论(0) 推荐(0) 编辑

2013年10月10日

摘要: Spiraly print n*n matrix.Eg: [1,2,3,4][12,13,14,5][11,16,15,6][10,9,8,7]Should print1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16螺旋输出n*n矩阵分析:n*n矩阵可分为n-2层输出,每层按照顺时针方向输出,每层输出的开始元素下标为 A[i][i]public class PrintMatrix { /** * question: * Spiraly print n*n matrix. Eg: [1,2,3,4] [12,13,... 阅读全文
posted @ 2013-10-10 23:22 逍遥骑士 阅读(177) 评论(0) 推荐(0) 编辑

2013年9月28日

摘要: 1000 elements in one bag and 1 million elements in another. how do you find common elements among them. Also give the complexity of your solution.翻译:1000个元素在一个bag中,另外1000000个元素在另一个bag中,如何找到他们之间相同的元素?同时给出你的解决方案的复杂度。先解释bag:袋子和Set类似, 不一样的是: 袋子里面对每个key计数,所以如果同一个key被加入多次那么可以通过接口获取这个key在这个袋子里面的个数。i) HashB 阅读全文
posted @ 2013-09-28 20:16 逍遥骑士 阅读(116) 评论(0) 推荐(0) 编辑

摘要: 题1:给定一个字符串、一个起始字符和一个终止字符,找起始字符和终止字符之间的字符串。public static void main(String[] args) { String str = "abcdcbaabcdfasdfbadbcbdaaosjfabcs"; String firstChar = "b"; String lastChar = "c"; int firstCharIndex = str.indexOf(firstChar); int lastCharIndex = str.lastIndexOf(lastChar) 阅读全文
posted @ 2013-09-28 19:49 逍遥骑士 阅读(146) 评论(0) 推荐(0) 编辑

2013年5月7日

摘要: 工作中用到反射,代码记录如下public String callXMLHandler(Object obj) throws IllegalArgumentException, IllegalAccessException{ Class clazz = (Class)obj.getClass(); Class clazzSuper = (Class) clazz.getSuperclass();//获得父类的Class Field field[] = clazz.getDeclaredFields();//getDeclaredFields 无法获得继承属性 //System.out... 阅读全文
posted @ 2013-05-07 11:03 逍遥骑士 阅读(233) 评论(0) 推荐(0) 编辑

2013年4月26日

摘要: 代理模式代理模式是常用的java设计模式,他的特征是代理类与委托类实现同样的接口,代理类主要负责为委托类预处理消息、过滤消息、把消息转发给委托类,以及事后处理消息等。代理类与委托类之间通常会存在关联关系,一个代理类的对象与一个委托类的对象关联,代理类的对象本身并不真正实现服务,而是通过调用委托类的对象的相关方法,来提供特定的服务。按照代理的创建时期,代理类可以分为两种。静态代理:由程序员创建或特定工具自动生成源代码,再对其编译。在程序运行前,代理类的.class文件就已经存在了。动态代理:在程序运行时,运用反射机制动态创建而成。静态代理不多说,主要说一下动态代理:JDK动态代理中包含一个类和一 阅读全文
posted @ 2013-04-26 17:29 逍遥骑士 阅读(211) 评论(0) 推荐(0) 编辑

2013年4月24日

摘要: log4j.properties 使用一.参数意义说明输出级别的种类ERROR、WARN、INFO、DEBUGERROR 为严重错误 主要是程序的错误WARN 为一般警告,比如session丢失INFO 为一般要显示的信息,比如登录登出DEBUG 为程序的调试信息配置日志信息输出目的地log4j.appender.appenderName = fully.qualified.name.of.appender.class1.org.apache.log4j.ConsoleAppender(控制台)2.org.apache.log4j.FileAppender(文件)3.org.apache.lo 阅读全文
posted @ 2013-04-24 10:41 逍遥骑士 阅读(111) 评论(0) 推荐(0) 编辑