the above
public static book getbook ()
{
return new book ();
}
In fact, a static method (static method) is established. One of the characteristics of a static method is that it can be directly called by a class without creating a new object (or instance), so it can be directly called by a Book class, so there will be Book mybook = Book.GetBook (); This call, in fact, can be written as Book mybook = new Book (); To create a new object, and the GetBook () method actually constructs a static method, creates a new object in the method, and then returns an object (in fact, it is the reference of the object, and the name of the new object is the reference name, although it is similar to the pointer in C, it is still very different), so you can also regard the object as a data type, like return false; Wait, you can return integer, Boolean, and of course you can return an object type (which can be understood in this way), so return new book;; It is an object type returned, which is not much different from the method of creating another new object above. It may be that the idea of creating a new object is different. As for the real difference, I have no clue for the time being, but I hope you will forgive me.
I am also a beginner in java, and I am still reading the whole book. I hope you are satisfied with the answer. If there are other understandings, I still hope to know a thing or two, and I am grateful.
-answered by jiezi