Some defects in Java

xiaoxiao2021-03-06  91

Just starting to enter the Java language, if you are not right, please also give a guidance! Long-term short saying, defects are as follows:

Parameters: No OUT type parameters, the parameters cannot be passed to the call, such as if I have:

Public Static Bool Parseint (String Text, Int Number) {

Try {

Number = integer.parseint (text);

} catch (exception ex) {

Return False;

}

Return True;

}

Because there is no OUT type parameter in Java, I can't be very convenient to call it:

INT number = 0;

String Numbertoparse = "100";

IF (PARSEINT (Numbertoparse, Number) {

// Process the number parse.

// ......

}

In fact, I hope that Java supports simultaneous support for IN, OUT, In-Out, and now, Java only supports IN. Interface: The interface in Java has a lot of limitations. It is used up and its inconvenience. An interface will not be compatible with another interface. In other words, the two interfaces can not always exist at the same time. This is a very tricky and no Walk Around. The problem. Specific examples are as follows: If I get two interfaces from two third parties, Inumber, IclassStructure:

Public interface inumber {

Inumber Parse (String Text);

}

Public interface iclassstructure {

IclassStructure Parse (String text);

}

This is two completely unsatisfactory interfaces, which don't have any business relationships except for a PARSE method. Note that the signature of the two interfaces is the same, but the return type is different, which means that these two interfaces cannot be implemented in a Java class. This is what I said without Walk Around, you can try A solution, pay attention to the interface from a third party, so I can't change the source code of one of the interfaces. Another question is if the type returned by the two interfaces is the same, such as Void, then there is no syntax error to implement them, but the meaning of the two interfaces is different, then why can't I do Different logic interfaces? Java actually made me unexpectedly in terms of the most critical interface, I know that OOD (Object Oriented Design) is mainly relatively perfect, but the interface in Java actually has so much. The limitations are really disappointing. It is recommended that Java increases the mechanism for different interfaces to different interfaces, which can also solve the first problem. By the way, .NET can be achieved in different interfaces.

转载请注明原文地址:https://www.9cbs.com/read-106882.html

New Post(0)