Can you declare a static variable in a method?

Answer Posted / murali

No, Static variables can be declared as a class attributes,
for example,
public classA{
static String m2="xyz"; // this is correct form
public static void main(String args[]){
static String m1="abc"; // this gives an error
(illegal modifier for parameter;;....)
}
}

Is This Answer Correct ?    25 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is command line used for?

585


What is http client in java?

515


State one difference between a template class and class template.

618


What is the difference between exception and error in java?

486


Can we override the private methods?

518






How do you differentiate abstract class from interface?

523


How does map works in java?

507


What are the differences between Java 1.0 and Java 2.0?

1670


Can we write any code after throw statement?

599


Why are the destructors for base class and derived class called in reverse order when the program exits

1701


What is the difference between a break statement and a continue statement?

595


What is the difference between variable & constant?

536


Hi i am creating desktop application in that i want calling to mobile number. i have java telephone api (JTAPI) but i dont understand how it configure & use plese help me

1356


difference between byte stream class and character stream class?

4079


What is a numeric format?

559