What is the importance of having variables declared as "Private Static". Y can't we just have only private variables?
Printable View
What is the importance of having variables declared as "Private Static". Y can't we just have only private variables?
You can have private variables. Please provide an example that demonstrates exactly what you're talking about.
Public Class Test
{
private static int count=10;
public void method()
{
}
}
Whats the importance of having private static variables?
Making a variable private means that it is private, and making it static means that it is static.Quote:
Whats the importance of having private static variables?
The importance of a variable being one or the other or both or neither depends on your code. You declare it to be the way you want it to be.
-----
Sorry for merely giving links. But twenty word summaries are apt be shallow (at best) or misleading (more likely). And it strikes me that you will make the most progress understanding the significance of these keywords if you google, read, and think a little about what they mean.
If what you find is obscure, or strikes you as wrong, then post your ideas as they will form a good basis for a specific discussion.