Static and non static class methods question
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.###");
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?
EDIT: I just posted this here. http://www.coderanch.com/t/537914/ja...ethods#2440191