Similar to -Why are static variables considered evil?
I am also a novice programmer in the industry. I am seeing a lot of static variables in all classes declared throughout the application. What is the advantage of making class variables static?
I notice that every class contains at least one static variable.
Example:
public class FileWriter{
private static Properties configProps = null ;
private static String propertyFile = "config/database.properties";
private static String LOG_PROPERTIES_FILE = "config/log4j.properties";
.
.
.
I understand that these variables will be common for all objects. Say, object1 of FileWriter and object2 of FileWriter are using the same variable configProps created at only one location in the memory?
In the below example, numberA should not be a static variable? What will happen if it is declared static?
public class sumFinder{
private int numberA=0;
}
Please excuse me if it is too silly.
Thanks