I just found a method declared in Java 5: Integer. getInteger (String ):
Http://java.sun.com/j2se/1.5.0/docs/api/java/lang/Integer.html#getInteger (java. lang. String)
Obtains the integer of the system Attribute Based on the specified name.
The first parameter is considered as the name of the system property. System properties can be accessed through the System. getProperty (java. lang. String) method. The property value string is interpreted as an Integer and returned as an Integer representing the value. You can find detailed descriptions of possible numeric formats in the getProperty definition description.
Let me see if I understand:
Integer. valueOf (String) converts a String to a number by assuming that String represents a value. That is, Integer. valueOf ("12345") returns the number 12345.
Integer. getInteger (String) converts String into a number by assuming that String is the name of a system attribute value. That is to say, Integer. getInteger ("12345") should be null.
Who would think there is a clear difference between the two? How many bugs are caused by the use of valueOf but getInteger?
This method overload is called the near-phrase overloading ). This is the term I just invented.It means that people use very similar terms to express completely different things. Let's take a look at the two words x and y. In one case, they are used for gm (x) and gm (y '), in another context, cm (x) and cm (y) are used '). If you use
- distance(gm(x), gm(y))< distance(cm(x), cm(y))
This is an incorrect y usage for x! You should use variable names other than x and y in this context. In fact, that method should be called getIntegerProperty.
This is the worst case of ambiguity I have seen in Java. They should make things more beautiful.
Update: The result is a worse one: Boolean. getBoolean ("true"). The result is equal to Boolean. FALSE.