Hi, I am reading a book on
java , and it looks like this is true.
Static methods can be called without an object of that class being created.
such as Math.sqrt()
and Non static methods must have a Class object created to call the class methods.
such as DecimalFormat fmt = new DecimalFormat ("0.###");
fmt.format(circumference);
the "format" DecimalFormat method is not static so we need the fmt object.
My question is. Why not make all of our methods static so we never need to make an object? please. thank you. Derek
also, my book seems to create objects in 2 ways
way 1:
String thisString = "this is a string object";
way 2: Random generator = new Random();
isn't String thisString a variable?
I previously posted this
HERE