\u6ce8: Double, Float, Long \u8f6c\u6210\u5b57\u4e32\u7684\u65b9\u6cd5\u5927\u540c\u5c0f\u5f02.<\/p>\n
\r\nint -> String\r\nint i=12345;\r\n\r\nString s=\"\";\r\n\r\n\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff1as=i+\"\";\r\n\r\n\u7b2c\u4e8c\u79cd\u65b9\u6cd5\uff1as=String.valueOf(i);\r\n<\/pre>\n\u8fd9\u4e24\u79cd\u65b9\u6cd5\u6709\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u4f5c\u7528\u662f\u4e0d\u662f\u4e00\u6837\u7684\u5462\uff1f\u662f\u4e0d\u662f\u5728\u4efb\u4f55\u4e0b\u90fd\u80fd\u4e92\u6362\u5462\uff1f<\/p>\n
\r\nString -> int\r\ns=\"12345\";\r\n\r\nint i;\r\n\r\n\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff1ai=Integer.parseInt(s);\r\n\r\n\u7b2c\u4e8c\u79cd\u65b9\u6cd5\uff1ai=Integer.valueOf(s).intValue();\r\n<\/pre>\n\u8fd9\u4e24\u79cd\u65b9\u6cd5\u6709\u4ec0\u4e48\u533a\u522b\u5462\uff1f\u4f5c\u7528\u662f\u4e0d\u662f\u4e00\u6837\u7684\u5462\uff1f\u662f\u4e0d\u662f\u5728\u4efb\u4f55\u4e0b\u90fd\u80fd\u4e92\u6362\u5462\uff1f<\/p>\n
\u4ee5\u4e0b\u662f\u7b54\u6848\uff1a<\/p>\n
\r\n\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff1as=i+\"\"; \/\/\u4f1a\u4ea7\u751f\u4e24\u4e2aString\u5bf9\u8c61\r\n\r\n\u7b2c\u4e8c\u79cd\u65b9\u6cd5\uff1as=String.valueOf(i); \/\/\u76f4\u63a5\u4f7f\u7528String\u7c7b\u7684\u9759\u6001\u65b9\u6cd5\uff0c\u53ea\u4ea7\u751f\u4e00\u4e2a\u5bf9\u8c61\r\n\r\n\u7b2c\u4e00\u79cd\u65b9\u6cd5\uff1ai=Integer.parseInt(s); \/\/\u76f4\u63a5\u4f7f\u7528\u9759\u6001\u65b9\u6cd5\uff0c\u4e0d\u4f1a\u4ea7\u751f\u591a\u4f59\u7684\u5bf9\u8c61\uff0c\u4f46\u4f1a\u629b\u51fa\u5f02\u5e38\r\n\r\n\u7b2c\u4e8c\u79cd\u65b9\u6cd5\uff1ai=Integer.valueOf(s).intValue(); \/\/Integer.valueOf(s) \u76f8\u5f53\u4e8e new Integer(Integer.parseInt(s))\uff0c\u4e5f\u4f1a\u629b\u5f02\u5e38\uff0c\u4f46\u4f1a\u591a\u4ea7\u751f\u4e00\u4e2a\u5bf9\u8c61\r\n<\/pre>\nJava\u6570\u636e\u7c7b\u578b\u8f6c\u6362<\/strong><\/div>\n\u8fd9\u662f\u4e00\u4e2a\u4f8b\u5b50,\u8bf4\u7684\u662fJAVA\u4e2d\u6570\u636e\u6570\u578b\u7684\u8f6c\u6362.\u4f9b\u5927\u5bb6\u5b66\u4e60\u5f15<\/p>\n
\u5b9e\u4f8b<\/p>\n
\r\nimport java.sql.Date;\r\npublic class TypeChange {\r\npublic TypeChange() {\r\n}\r\n\/\/change the string type to the int type\r\npublic static int stringToInt(String intstr)\r\n{\r\n Integer integer;\r\n integer = Integer.valueOf(intstr);\r\n return integer.intValue();\r\n}\r\n\/\/change int type to the string type\r\npublic static String intToString(int value)\r\n{\r\n Integer integer = new Integer(value);\r\n return integer.toString();\r\n}\r\n\/\/change the string type to the float type\r\npublic static float stringToFloat(String floatstr)\r\n{\r\n Float floatee;\r\n floatee = Float.valueOf(floatstr);\r\n return floatee.floatValue();\r\n}\r\n\/\/change the float type to the string type\r\npublic static String floatToString(float value)\r\n{\r\n Float floatee = new Float(value);\r\n return floatee.toString();\r\n}\r\n\/\/change the string type to the sqlDate type\r\npublic static java.sql.Date stringToDate(String dateStr)\r\n{\r\n return java.sql.Date.valueOf(dateStr);\r\n}\r\n\/\/change the sqlDate type to the string type\r\npublic static String dateToString(java.sql.Date datee)\r\n{\r\n return datee.toString();\r\n}\r\n \r\npublic static void main(String[] args)\r\n{\r\n java.sql.Date day ;\r\n day = TypeChange.stringToDate(\"2003-11-3\");\r\n String strday = TypeChange.dateToString(day);\r\n System.out.println(strday);\r\n}\r\n \r\n}\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"A. \u6709\u4e24\u4e2a\u65b9\u6cd5: 1\u3001 int i = Integer.parseInt([String]); \u6216 i = […]<\/p>\n","protected":false},"author":1903,"featured_media":214996,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[55],"tags":[],"class_list":["post-214975","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-thread"],"acf":[],"_links":{"self":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/214975","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/users\/1903"}],"replies":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/comments?post=214975"}],"version-history":[{"count":7,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/214975\/revisions"}],"predecessor-version":[{"id":215086,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/posts\/214975\/revisions\/215086"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media\/214996"}],"wp:attachment":[{"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/media?parent=214975"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/categories?post=214975"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gulass.cn\/wp-json\/wp\/v2\/tags?post=214975"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}