Plus sign interview knowledge points in Java

End and separation 2021-09-15 09:25:59
Front questions

Java Of “+” What are the functions of the number

Whether the plus sign is a symbol overload

Interview answer

There are two main functions , One is arithmetic operation , Add . Second, the role of string connectors , What's actually called is Java Method to connect

Java There is no symbol overload in , Decompile class file , Low version JDK It's called StringBuilder.append Method ,JDK9 Then it calls the method of the string connection factory StringConcatFactory.makeConcatWithConstants

Java Interview knowledge points in the plus sign _Javakafi



One 、 Arithmetic operator

Basic addition operation 1+1=2

Two 、 String connector

For connecting characters , A kind of grammar sugar ,Java There is no symbol overload in

After decompilation ,class file

Decompile screenshot

JDK edition 11

find class route ,

javap -verbose Example.class Deal with , Look at the java Bytecode generated by compiler ,

String concatenation is to call StringConcatFactory.makeConcatWithConstants Accomplished

Java Interview knowledge points in the plus sign _Javakafi_02
Please bring the original link to reprint ,thank
Similar articles