What is the importance of having variables declared as "Private Static". Y can't we just have only private variables?
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
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.
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Public Class Test
{
private static int count=10;
public void method()
{
}
}
Whats the importance of having private static variables?
Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!
Making a variable private means that it is private, and making it static means that it is static.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.
KevinWorkman (June 28th, 2012)