Meaningless Drivel is fun!
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 Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "HFS Doubt" Watch "HFS Doubt" New topic

HFS Doubt

Ramesh NarayananPerumal

Joined: Feb 14, 2006
Posts: 2
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?

Christophe Verré

Joined: Nov 24, 2005
Posts: 14688

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
I agree. Here's the link:
subject: HFS Doubt
It's not a secret anymore!