Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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 main in java?

1079


What is bool mean?

1020


Which is illegal identifier in java?

1028


Can we declare the static variables and methods in an abstract class?

953


What is final method?

1018


What is the difference between hashset and treeset in java?

1014


What is the advantage of functional interface in java 8?

952


What is a method type?

952


What do you understand by casting in java language?

985


How do you compare two strings lexicographically?

894


Write a java program to count the number of words present in a string?

947


How do you bind variables?

1032


what is function overloading in java?

1230


In the below example, how many string objects are created?

987


Can we clone singleton object in java?

969