1) I/O: This is actually meaningless, but java's stream concept is similar to C #'s stream concept, and the inheritance system is similar, but in Java it is Input, output, while C # contains Read and Write. in fact, most of the method names in each supported class are the same. of course, C # is compatible with some original file reads and writes in addition to stream support.
2) serialization: the serialization of objects is supported by both methods. Of course, except binary serialization in C, it can also be serialized into XML format (not available in Java ). the purpose of serialization is similar (mainly RMI ).
3) reflection mechanism: the reflection mechanism is similar to that of the two. Of course, in this aspect, C # should be improved and the element Attribute should be added) (there are no similar things in Java. I haven't learned it yet. The annotations in Java should be expressed in C ). I know more about the internal reflection mechanism of C #, but I don't know much about Java. But this kind of things has been implemented in Delphi for a long time, but it is not as perfect as C. Of course, delphi is still lacking, and Java and C # are enough.
4) multithreading: This is actually something unrelated to the language. However, the basic implementation methods in Java and C # are similar, and the class names are the same, but the method name is run, execute. java can use the Runable interface to simplify thread creation. in C #, methods and delegates (including Lamda expressions) are used to do the same job. in C #, the thread pool (strictly speaking, it belongs to the framework rather than the language). Background tasks and other things can be seen as secondary encapsulation and have no value for comparison.
5) code injection: Both C # and Java are based on the intermediate language (C #'s IL and Java bytecode). Therefore, it is convenient to implement code injection, therefore, the aspect-oriented implementation method in Spring is also easy to implement in C # (refer to my previous blog post ).
6) overload: both parties support method overloading, And the rules are similar. in order to simplify this type of overload C #, you can use the parameter default and params keywords to reduce the number of methods, such as public void DoF (params object [] pms ), you can call DoF (p1) or DoF (p1, p2 ...) etc., this is used in Java "... "To define: public void DoF (Object... pms ). java does not support parameter defaults, which are convenient but not required (supported by Delphi for a long time ).
7) Delegate and event: This is something with a function pointer, callback method, and so on. After looking at it, there is no similar concept in Java. If you need to implement something similar, design Patterns are required, such as observer and proxy. C # and Delphi all have this, which is actually a very useful thing. I think Java can be used as a reference for upgrading. (I checked that Java does not have similar things. Of course, it may be that I am ignorant ), java does not. This may be due to the pursuit of pure object-oriented language and the uneasiness of pointer abuse.
Supplement: after reading the materials, Java also implements callback functions. But in fact, this is not a real callback function, but a similar function simulation. because it is not a method but a class. from this point of view, the reason I mentioned earlier about Java's absence of delegation and events is probably correct.
8) inverter and collaborative Transformation: in fact, as long as it is object-oriented programming, there are two kinds of inheritance (method parameters and return values ). But you only need to grasp one principle: the son can also use where Lao Tzu can use it, and vice versa.
Conclusion: If you know more about data structures, operating systems, algorithms, and object-oriented programming, it is easier to convert each other. As a cool B programmer, there is no need to worry about the ranking of language. To learn a language, you must have the consciousness above the language level.