易截截图软件、单文件、免安装、纯绿色、仅160KB

JSP/JAVA 编程参考

第1条  How to Write an Equality Method in Java  
http://www.artima.com/lejava/articles/equality.html
How to Write an Equality Method in Java
by Martin Odersky, Lex Spoon, and Bill Venners
June 1, 2009
Summary
This article describes a technique for overriding the equals method that preserves the contract of equals even when subclassses of concrete classes add new fields.
In Item 8 of Effective Java1, Josh Bloch describes the difficulty of preserving the equals contract when subclassing as a “fundamental problem of equivalence relations in object-oriented languages.” Bloch writes:
There is no way to extend an instantiable class and add a value component while preserving the equals contract, unless you are willing to forgo the benefits of object-oriented abstraction.
Chapter 28 of Programming in Scala shows an approach that allows subclasses to extend an instantiable class, add a value component, and nevertheless preserve the equals contract. Although in the technique is described in the book in the context of defining Scala classes, it is also applicable to classes defined in Java. In this article, we present the technique using text adapted from the relevant section of Programming in Scala, but with the code examples translated from Scala into Java.
第2条 jsp使用URL编码传递中文参数问题
http://blog.csdn.net/jxcjxinxing/archive/2007/12/30/1469924.aspx
Jsp页面使用URL编码传递中文参数的情况下,在参数的解析过程中会出现乱码。由于java在设计的时候考虑到了国际化的问题,在java源程序编译成字节码的时候默认使用的是UTF-8编码。而在web运用上,由于不同的浏览器向服务器发送的信息采用的编码方式不同,在由像tomcat之类的服务器解码的时候会由于编码方式的不同而产生乱码,这是一个会困扰jsp初学者很久的问题。
举例说明:
    String sContent = "中文 参数";
    如果不做任何处理就直接传递,中文也许没有问题(但不保证),但空格肯定会有问题,到接收页面无法识别。
解决办法1:
java.net.URLEncoder.encode(sContent,"gb2312"); 然后再


相关文档:

Java 几种排序法

这里主要对8种排序算法做个总结,分别是插入排序,选择排序,冒泡排序,希尔排序,归并排序,堆排序,快速排序以及基数排序。
1、 插入排序
比较和交换的时间复杂度为O(n^2),算法自适应,对于数据已基本有序的情况,时间复杂度为O(n),算法稳定,开销很低,适合于数据已基本有序或者数据量小的情况。
public void ins ......

java 事务处理

如果对数据库进行多次操作,每一次的执行或步骤都是一个事务.如果数据库操作在某一步没有执行或出现异常而导致事务失败,这样有的事务被执行有的就没有被执行,从而就有了事务的回滚,取消先前的操作.....
JavaBean中使用JDBC方式进行事务处理
public int delete(int sID) {
  dbc = new DataBaseConnection();
  Connect ......

java面试中要注意的地方


1.Java里面使用
static
方法有什么好处?
答:在项目中,对于频繁使用的方法,使用static
修饰会提高效率吗? 
静态方法的好处就是不用生成类的实例就能直接调用和对象无关
你不用生成对象就能用这个方法了,不是提高效率?你生成对象得占用内存空间啊 
至于静态属性也能提高效率,你普通的属性每个类对 ......

Java取得代码所在行号的方法

用C的人一定知道__FILE__和__LINE__,但是Java中 并没有这样的定义,有时候调试多线程就很不方便,没办法,自己动手,丰衣足食~用下面的函数取得当前行号。
函数:
/**
*得到Exception所在代码的行数
*如果没有行信息,返回-1
*/
public static int getLineNumber(Exception e){
StackTraceElement[] trace =e.getStac ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号