Java 基本数据类型、包装类和 String 之间的相互转换
Java\u5728\u7684\u5305\u88c5\u7c7b\u3001\u57fa\u672c\u6570\u636e\u7c7b\u578b\u548c\u7b80\u5355\u5b57\u7b26\u4e32\u4e4b\u95f4\u53ef\u4ee5\u8fdb\u884c\u76f8\u4e92\u8f6c\u6362\u3002\n\n1\u3001\u57fa\u672c\u6570\u636e\u7c7b\u578b\u8f6c\u6362\u4e3a\u5305\u88c5\u7c7b\uff1a\n - \u4f7f\u7528\u5305\u88c5\u7c7b\u7684\u6784\u9020\u65b9\u6cd5\u8fdb\u884c\u8f6c\u6362\uff1a\u4f8b\u5982\uff0c\u5c06\u0069\u006e\u0074\u7c7b\u578b\u8f6c\u6362\u4e3a\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u7c7b\u578b\uff1a\u0060\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0020\u006e\u0075\u006d\u0020\u003d\u0020\u006e\u0065\u0077\u0020\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u0028\u0031\u0030\u0029\u003b\u0060\n - \u4f7f\u7528\u0076\u0061\u006c\u0075\u0065\u004f\u0066\u006d\u0065\u0074\u0068\u006f\u0064\u008fdb\u884c\u8f6c\u6362\uff1a\u4f8b\u5982\uff0c\u5c06\u0064\u006f\u0075\u0062\u006c\u0065\u7c7b\u578b\u8f6c\u6362\u4e3a\u0044\u006f\u0075\u0062\u006c\u0065\u7c7b\u578b\uff1a\u0060\u0044\u006f\u0075\u0062\u006c\u0065\u0020\u006e\u0075\u006d\u0020\u003d\u0020\u0044\u006f\u0075\u0062\u006c\u0065\u002e\u0076\u0061\u006c\u0075\u0065\u004f\u0066\u0028\u0033\u002e\u0031\u0034\u0029\u003b\u0060\n\n2\u3001\u5305\u88c5\u7c7b\u8f6c\u6362\u4e3a\u57fa\u672c\u6570\u636e\u7c7b\u578b\uff1a\n - \u8c03\u7528\u5305\u88c5\u7c7b\u7684\u0078\u0078\u0078\u0056\u0061\u006c\u0075\u0065\u004d\u0065\u0074\u0068\u006f\u0064\u8fdb\u884c\u8f6c\u6362\uff0c\u4f8b\u5982\uff0c\u5c06\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u7c7b\u578b\u8f6c\u6362\u4e3a\u0069\u006e\u0074\u7c7b\u578b\uff1a\u0060\u0069\u006e\u0074\u0020\u006e\u0075\u006d\u0020\u003d\u0020\u0069\u006e\u0074\u0065\u0067\u0065\u0072\u004f\u0062\u006a\u002e\u0069\u006e\u0074\u0056\u0061\u006c\u0075\u0065\u0028\u0029\u003b\u0060\n\n3\u3001\u7b80\u5355\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u57fa\u672c\u6570\u636e\u7c7b\u578b\u6216\u5305\u88c5\u7c7b\uff1a\n - \u4f7f\u7528\u5305\u88c5\u7c7b\u7684\u0076\u0061\u006c\u0075\u0065\u004f\u0066\u006d\u0065\u0074\u0068\u006f\u0064\u8fdb\u884c\u8f6c\u6362\uff0c\u4f8b\u5982\uff0c\u5c06\u7b80\u5355\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u0069\u006e\u0074\u7c7b\u578b\uff1a\u0060\u0069\u006e\u0074\u0020\u006e\u0075\u006d\u0020\u003d\u0020\u0049\u006e\u0074\u0065\u0067\u0065\u0072\u002e\u0076\u0061\u006c\u0075\u0065\u004f\u0066\u0028\u0022\u0031\u0030\u0022\u0029\u003b\u0060\n - \u4f7f\u7528\u5305\u88c5\u7c7b\u7684\u0070\u0061\u0072\u0073\u0065\u0058\u0078\u0078\u004d\u0065\u0074\u0068\u006f\u0064\u8fdb\u884c\u8f6c\u6362\uff0c\u4f8b\u5982\uff0c\u5c06\u7b80\u5355\u5b57\u7b26\u4e32\u8f6c\u6362\u4e3a\u0066\u006c\u006f\u0061\u0074\u7c7b\u578b\uff1a\u0060\u0066\u006c\u006f\u0061\u0074\u0020\u006e\u0075\u006d\u0020\u003d\u0020\u0046\u006c\u006f\u0061\u0074\u002e\u0070\u0061\u0072\u0073\u0065\u0046\u006c\u006f\u0061\u0074\u0028\u0022\u0033\u002e\u0031\u0034\u0022\u0029\u003b\u0060\n\n4\u3001\u57fa\u672c\u6570\u636e\u7c7b\u578b\u6216\u5305\u88c5\u7c7b\u8f6c\u6362\u4e3a\u7b80\u5355\u5b57\u7b26\u4e32\uff1a\n - \u4f7f\u7528\u0053\u0074\u0072\u0069\u006e\u0067\u7c7b\u7684\u0076\u0061\u006c\u0075\u0065\u004f\u0066\u006d\u0065\u0074\u0068\u006f\u0064\u8fdb\u884c\u8f6c\u6362\uff0c\u4f8b\u5982\uff0c\u5c06\u0069\u006e\u0074\u7c7b\u578b\u8f6c\u6362\u4e3a\u7b80\u5355\u5b57\u7b26\u4e32\uff1a\u0060\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0074\u0072\u0020\u003d\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u002e\u0076\u0061\u006c\u0075\u0065\u004f\u0066\u0028\u0031\u0030\u0029\u003b\u0060\n - \u4f7f\u7528\u5305\u88c5\u7c7b\u7684\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u004d\u0065\u0074\u0068\u006f\u0064\u8fdb\u884c\u8f6c\u6362\uff0c\u4f8b\u5982\uff0c\u5c06\u0044\u006f\u0075\u0062\u006c\u0065\u7c7b\u578b\u8f6c\u6362\u4e3a\u7b80\u5355\u5b57\u7b26\u4e32\uff1a\u0060\u0053\u0074\u0072\u0069\u006e\u0067\u0020\u0073\u0074\u0072\u0020\u003d\u0020\u0064\u006f\u0075\u0062\u006c\u0065\u004f\u0062\u006a\u002e\u0074\u006f\u0053\u0074\u0072\u0069\u006e\u0067\u0028\u0029\u003b\u0060\n\n\u6ce8\u610f\uff1a\n - \u5728\u8f6c\u6362\u65f6\uff0c\u9700\u8981\u786e\u4fdd\u7b80\u5355\u5b57\u7b26\u4e32\u7684\u5185\u5bb9\u662f\u6709\u6548\u7684\u6570\u636e\uff0c\u5426\u5219\u4f1a\u53d1\u751f\u9519\u8bef\u3002\n - \u5728\u8f6c\u6362\u7b80\u5355\u5b57\u7b26\u4e32\u4e3a\u57fa\u672c\u6570\u636e\u7c7b\u578b\u65f6\uff0c\u5982\u679c\u7b80\u5355\u5b57\u7b26\u4e32\u4e2d\u5305\u542b\u975e\u6570\u5b57\u5185\u5bb9\uff0c\u4f1a\u53d1\u751f\u004e\u0075\u006d\u0062\u0065\u0072\u0046\u006f\u0072\u006d\u0061\u0074\u0045\u0078\u0063\u0065\u0070\u0074\u0069\u006f\u006e\u3002\n\n\u672c\u7bc7\u6587\u7ae0\u4ecb\u7ecd\u4e86\u004a\u0061\u0076\u0061\u0020\u4e2d\u7684\u57fa\u672c\u6570\u636e\u7c7b\u578b\u3001\u5305\u88c5\u7c7b\u548c\u7b80\u5355\u5b57\u7b26\u4e32\u4e4b\u95f4\u7684\u76f8\u4e92\u8f6c\u6362\u65b9\u6cd5\uff0c\u5e0c\u671f\u80fd\u591f\u5e2e\u52a9\u4f60\u66f4\u597d\u5730\u7406\u89e3\u548c\u4f7f\u7528\u004a\u0061\u0076\u0061\u0020\u7684\u8fd9\u4e9b\u6570\u636e\u7c7b\u578b\u3002
原文地址: http://www.cveoy.top/t/topic/pY2a 著作权归作者所有。请勿转载和采集!