Jsp declaration element

Posted by Stardust on Stack Overflow See other posts from Stack Overflow or by Stardust
Published on 2010-04-07T20:29:43Z Indexed on 2010/04/07 20:53 UTC
Read the original article Hit count: 250

Filed under:
|
|
<%!
class father {
static int s = 0;
}
%>

<%
father f1 = new father();
father f2 = new father();
f1.s++;
out.println(f2.s); // It must print "1"
%>

When I run the file, I got this error. Can anybody explain?

"The field s cannot be declared static; static fields can only be declared in static or top level types"

© Stack Overflow or respective owner

Related posts about jsp

Related posts about java