Can we declare static variables in JSP page.
Answers were Sorted based on User's Feedback
yes
we should do in jsp declarative tag only.if we specify
variables in declaration tag, it belongs to class.
<%! static int i=0; %>
and u can not define static variable in scriptlet(<% %>).
as we know that we can not declare a static variable in a
method.
Is This Answer Correct ? | 42 Yes | 5 No |
Answer / vijayakumar chinnasamy
In Declaration tag (<%! -- %>), you can able declare the
static variable,class, define methods.
Is This Answer Correct ? | 23 Yes | 4 No |
Answer / srinu
yes we declare the varible as static in a jsp.we declare the
static varible in the declaration tag.
ex:-
<%! static int a=10;%>
Is This Answer Correct ? | 12 Yes | 3 No |
Why unicode is important?
Why string objects are immutable in java?
What is classpath?
Is int a class in java?
What is the public method modifier?
What are the Static and Dynamic Variables? Differentiate them.
How do you escape a string?
Why use string handling in Java?
How do you remove all elements from an arraylist in java?
public class AboutStrings{ public static void main(String args[]){ String s1="hello"; String s2="hel"; String s3="lo"; String s4=s2+s3; //to know the hash codes of s1,s4. System.out.println(s1.hashCode()); System.out.println(s4.hashCode()); // these two s1 and s4 are having same hashcodes. if(s1==s4){ System.out.println("s1 and s4 are same."); }else System.out.println("s1 and s4 are not same."); } } Somebody told me that, == operator compares references of the objects. In the above example even though s1 and s4 are refering to same object(having same hash codes), it is printing s1 and s4 are not same. Can anybody explain in detail why it is behaving like this? Thanks in Advance RavuriVinod
What is mysql driver class name?
How to invoke external process in java.