This is an article written to beginners. It is also the first time I published an article, please don't read it, I can help me point out the mistakes.
This is an article I saw on the JavaWorld website, so by the way, it is possible to have a big difference with the original document, not directly translated by the original text, it is after reading some of his understanding, barely calculate the original. The English title of the article is the title of the original text, the Chinese title is not its translation, but the idea of myself. If your English is good, you can take a look at the original text.
Http://www.javaworld.com/javaworld/javaqa/2001-11/02-QA-1109-BOOLEAN.HTML?
I hope this article will help beginners to help and enlighten:
On the basis of understanding this article, everyone must explicit in the Java language in the Java language is an object variable. This article is the best proof of this problem. In addition, the object package converts the Boolean value into a Boolean object using an object package (converted to the direct variable base type.). In the article, the conversion of these two variables mainly uses several static methods of object packages and objects. The use and use of these methods and object packages are not cumbersome, if there is a problem Please consult some information more, you can also send me an email.
my mail address is:
Kwaif@sina.com
In the original text, two methods were proposed to the string of boolean values to strings and compared.
The first method is:
Boolean Bool = true; string s = new boolean (bool) .tostring (); // Transform Bool to object S.Equals ("true"); / * where the Totring method is a inheritance method. All classes in Java are Object's inheritance. An important way to object is toString, which is used to convert objects to strings. * /
The second method is:
Boolean Bool = True; String S = String.Valueof (bool);
First, from the length of the code, the second method is obviously compacted than the first method; second, the first method introduces a completely unnecessary object during the conversion, so this is relative to the second method Incidentally, the waste of memory space is greatly slowed down. Therefore, it is recommended to use the second method.
From this simple example, you can see the advantages of object variables, as well as the necessity of some basic methods of object variables, and the author puts forward a good suggestion, which is to bring a document to JDK. At the same time, it is also reminding that the majority of beginners can think more about more comparisons, and the flexible language is often solving a problem. There are many ways to find the best, the original code is to find the best solution. This is An art of programming.