考虑我已将一个类声明为:
public class Calcultor{
public int cube(int n){return n*n;}
}
现在下面的声明都一样吗?
index.jsp:
<jsp:useBean id=obj class="Calculator"/> <% int m=obj.cube(5); out.println("cube of 5 is "+m) %>
index.jsp:
<% Calculator obj=new Calculator(); int m=obj.cube(5); out.println("cube of 5 is "+m); %>
如果两者相同,有什么优势?