Illegal modifier for parameter y, only final is permitted
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
error:-
Illegal modifier for parameter y, only final is permitted
IfClause.java :-
Screenshot is attached also for your reference

Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
as said by Christophe VerréYou cannot set visibility scopes (private,...) to local variables.
but why, may i know the reason behind this ?
Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
[My Blog]
All roads lead to JavaRanch
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6 - OCEJPAD 6
How To Ask Questions How To Answer Questions
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Rob Prime wrote:Static also doesn't apply to local variables, unlike in C / C++.
I actually like this feature in C/C++. Granted it is not really a local variable. It's more like a global variable that is private to the function.... or maybe it's more like a local variable, whose scope doesn't end when the function returns.
Henry
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
as said by Christophe VerréWould it make sense ? What benefits would you get by making it private ? Private to whom ? The Local variables scope is already well defined : within the scope of the method it lives in.
Thanks fro your response, i got it what you are saying.
Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
[b]
From another class, i have created the object of this class and accessed this abc() method...success..
But why i'm not able to access the field x inside this method ?
I can access any field i.e. global variables only but why can't for local variables ? how can i put values in this local field through the object created ?
please tell me this briefly...

Vinod Kumar Nair
"Any fool can write code that a computer can understan. Good programmers write code that humans can understand."
-
-
Number of slices to send:Optional 'thank-you' note:
-
-
Vinod Vijay wrote:Now i want to know that if there is method say abc() which is public for instance like :-
From another class, i have created the object of this class and accessed this abc() method...success..
But why i'm not able to access the field x inside this method ?
To put it in a simple way: because when the method call returns, the variable no longer exists.
Vinod Vijay wrote:I can access any field i.e. global variables only but why can't for local variables ? how can i put values in this local field through the object created ?
please tell me this briefly...![]()
A local variable is NOT a field. Have you ever heard of parameters?
luck, db
There are no new questions, but there may be new answers.
| What's that smell? I think this tiny ad may have stepped in something. Paul Wheaton's 16th Kickstarter: Gardening playing cards for gardeners and homesteaders https://coderanch.com/t/889615/Paul-Wheaton-Kickstarter-Gardening-playing |












