From compilation to runtime, how does Java String encoding really work

后端 未结 4 1682
深忆病人
深忆病人 2020-12-30 02:39

I recently realized that I don\'t fully understand Java\'s string encoding process.

Consider the following code:

public class Main
{
    public stati         


        
4条回答
  •  星月不相逢
    2020-12-30 03:13

    If you compile with different encodings, these encodings only affect your source files. If you don't have any special characters inside your sources, there will be no difference in the resulting byte code.

    For runtime, the default charset of the operating system is used. This is independent from the charset you used for compiling.

提交回复
热议问题