The number of bytes occupied by strings in Java is closely related to character encoding.
Java coding can actually involve these aspects: ide encoding, operating system default encoding, and Java character encoding.
For example, we use eclipse to compile JavaProgramYou can set the Java program encoding in the project attribute. If this parameter is not set, the program encoding is the operating system encoding by default.CodeFile encoding; or when we use Vim to write a Java program, you can set the system environment variable Lang, such as zh_CN.UTF-8, zh_cn.gb18030, etc. At this time, the code file encoding is the Lang specified encoding. This is the IDE encoding, IDE encoding is very important, for example, a Java code file is UTF-8 encoding, and your ide is gb18030 encoding, then the display will appear garbled.
Http://blog.csdn.net/xiaoyu714543065/article/details/7380191