Links

Lists

Latest Updates

Ruby On Rails List
Python list
Advanced Java
The JavaScript List
Apache Users
Full Disclosure
Linux Security

Search the archives!


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

problem with fianl & static variable.


  • From: deepesh at cistemsindia.com (deepesh)
  • Subject: problem with fianl & static variable.
  • Date: Sat Nov 12 19:33:26 2005

Hello Pratap,

        u r trying to create a static variable in a method which is not
possible. The static variables r class level variables and when the code is
compiled, the compiler considers the static variable 'once' as a class field
declaration. This hinders the parsing of the compiler as bracket mismatch and
so on.

so if u want a static variable, declare it outside the method block. Java
doesn't provide 'C' like feature of declaring static variable in the method.
Hope this solves ur problem.

Best
Deepesh


"Pratap Malani, Gurgaon" wrote:

> Hello all,
> This could be a simple problem but I m unable to understand. These are the
> lines of code I have written :
> Void function()
> {
>         final EditBox edit = this ;  // EditBox is my class with extends
> JTextBox.
>         static int once;
> once = 1;
> ..........
> ..........
> }
>
> when I compile it I get the following error.
>
> EditBox.java:57: '}' expected.
>                 final EditBox edit = this ;
>                                            ^
> EditBox.java:58: Statement expected.
>                 static int once;
>                 ^
> EditBox.java:59: Identifier expected.
>                 once = 1;
>                     ^
> 3 errors
>
> I cannot figure out what is wrong. Can anyone please help me.
> Thanks in advance.
>
> Bye.
> With Warm Regards And Best Wishes.
> Pratap Malani.
>
> ---
> To unsubscribe, mail advanced-java-unsubscribe@xxxxxxxxxxxxxxxx
> To get help, mail advanced-java-help@xxxxxxxxxxxxxxxx
-------------- next part --------------
A non-text attachment was scrubbed...
Name: deepesh.vcf
Type: text/x-vcard
Size: 231 bytes
Desc: Card for deepesh
Url : /lists/advanced-java/attachments/00000000/422f5f14/deepesh.vcf