aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes HFS Doubt Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFS Doubt" Watch "HFS Doubt" New topic
Author

HFS Doubt

Ramesh NarayananPerumal
Greenhorn

Joined: Feb 14, 2006
Posts: 2
Hi,
I am new for JavaRanch and preparing SCWCD.Pl clarify my doubts.
In Page 293:
<! int doubleCount(){
count = count*2;
return count %>
<! int count=1; %>

It is ok because java accepts forward referncing.

but in case of scriplet in page 300
<% int y = 5 + x; %>
<% int x = 2; %>
They mentioned this won't complie. Why it will not compile?

Ramesh.N
Christophe Verré
Sheriff

Joined: Nov 24, 2005
Posts: 14687
    
  16

Declaration of new variables into <%! %> will define the variable as class members. So you can refer to "count" into the "doubleCount" function.

However, declarations of new variable into scriplets (<% %> will define+ the variable locally. So you cannot reference x, as long as it has not been declared.


[My Blog]
All roads lead to JavaRanch
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: HFS Doubt