This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes EJB Certification (SCBCD/OCPJBCD) and the fly likes Programming restrictictions Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Certification » EJB Certification (SCBCD/OCPJBCD)
Bookmark "Programming restrictictions" Watch "Programming restrictictions" New topic
Author

Programming restrictictions

Peter Warde
Ranch Hand

Joined: Aug 18, 2004
Posts: 71
I know you can't use a static variable, but can you use a static final variable ie a constant? What about static methods in beans?
Severin Stoeckli
Ranch Hand

Joined: Jul 21, 2004
Posts: 62
If you use static methods in a helper class there's no problem. If you use static methods in your bean class directly there could be a problem, depending on your container implementation. The countainer is allowed to subclass your bean and could miss to take in count that you could made a static class.

Remark: don't use static members in helper classes!!! (they have tha same effect as in your bean class).
Roger Yates
Ranch Hand

Joined: Aug 31, 2004
Posts: 118
Using static *final* variables is ok (as long as it is not a final reference to a modifiable class instance!).
e.g. this would be ok:
static final int ONE = 1;
but this would not:
static final StringBuffer msg = new StringBuffer();

since you could still modify the data in the StringBuffer.


Cheers,<br />Roger<br />SCJP 1.2, 1.4, SCBCD 1.3, SCWCD 1.4
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Programming restrictictions
 
Similar Threads
how declare a variable global ?
How do we use global variables in servlets?
static variables
Fix an infity loop
final static variables in beans?