{"id":84251,"date":"2025-01-23T17:02:05","date_gmt":"2025-01-23T10:02:05","guid":{"rendered":"https:\/\/itviec.com\/blog\/?p=84251"},"modified":"2025-01-23T17:02:05","modified_gmt":"2025-01-23T10:02:05","slug":"cac-kieu-du-lieu-trong-java","status":"publish","type":"post","link":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/","title":{"rendered":"C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java A-Z: \u0110\u1ecbnh ngh\u0129a v\u00e0 C\u00e1ch s\u1eed d\u1ee5ng"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_84 counter-hierarchy ez-toc-counter ez-toc-grey ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">N\u1ed9i dung b\u00e0i vi\u1ebft<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #999;color:#999\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #999;color:#999\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#Kieu_du_lieu_nguyen_thuy_Primitive_Data_Type\" >Ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y (Primitive Data Type)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#Kieu_du_lieu_tham_chieu_Reference_Data_Type\" >Ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu (Reference Data Type)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#Kieu_du_lieu_khong_co_dinh_Special_Data_Type\" >Ki\u1ec3u d\u1eef li\u1ec7u kh\u00f4ng c\u1ed1 \u0111\u1ecbnh (Special Data Type)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#So_sanh_giua_kieu_du_lieu_nguyen_thuy_va_kieu_du_lieu_tham_chieu\" >So s\u00e1nh gi\u1eefa ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y v\u00e0 ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#Cach_su_dung_cac_kieu_du_lieu_trong_Java\" >C\u00e1ch s\u1eed d\u1ee5ng c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#Luu_y_khi_lam_viec_voi_cac_kieu_du_lieu_trong_Java\" >L\u01b0u \u00fd khi l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-7\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#Cac_cau_hoi_thuong_gap_ve_cac_kieu_du_lieu_trong_Java\" >C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-8\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#Tong_ket\" >T\u1ed5ng k\u1ebft<\/a><\/li><\/ul><\/nav><\/div>\n<p><em><strong>Ki\u1ec3u d\u1eef li\u1ec7u \u0111\u00f3ng vai tr\u00f2 quan tr\u1ecdng trong vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng Java, gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean x\u00e1c \u0111\u1ecbnh v\u00e0 qu\u1ea3n l\u00fd hi\u1ec7u qu\u1ea3 c\u00e1ch l\u01b0u tr\u1eef, x\u1eed l\u00fd d\u1eef li\u1ec7u trong ch\u01b0\u01a1ng tr\u00ecnh. Trong Java, vi\u1ec7c l\u1ef1a ch\u1ecdn \u0111\u00fang ki\u1ec3u d\u1eef li\u1ec7u kh\u00f4ng ch\u1ec9 gi\u00fap c\u1ea3i thi\u1ec7n hi\u1ec7u n\u0103ng m\u00e0 c\u00f2n gi\u1ea3m thi\u1ec3u c\u00e1c l\u1ed7i ti\u1ec1m \u1ea9n, \u0111\u1ea3m b\u1ea3o t\u00ednh ch\u00ednh x\u00e1c v\u00e0 b\u1ea3o tr\u00ec l\u00e2u d\u00e0i cho \u1ee9ng d\u1ee5ng. Hi\u1ec3u r\u00f5 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java l\u00e0 n\u1ec1n t\u1ea3ng c\u01a1 b\u1ea3n \u0111\u1ec3 ph\u00e1t tri\u1ec3n c\u00e1c gi\u1ea3i ph\u00e1p l\u1eadp tr\u00ecnh hi\u1ec7u qu\u1ea3 v\u00e0 t\u1ed1i \u01b0u.<\/strong><\/em><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ecdc b\u00e0i vi\u1ebft n\u00e0y \u0111\u1ec3 hi\u1ec3u th\u00eam v\u1ec1:<\/span><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Ph\u00e2n lo\u1ea1i c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong java<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">So s\u00e1nh gi\u1eefa c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00e1ch s\u1eed d\u1ee5ng c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong th\u1ef1c t\u1ebf<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">L\u01b0u \u00fd khi l\u00e0m vi\u1ec7c v\u1edbi ki\u1ec3u d\u1eef li\u1ec7u trong Java<\/span><\/li>\n<\/ul>\n<p><span style=\"font-weight: 400;\">Trong Java, ki\u1ec3u d\u1eef li\u1ec7u \u0111\u01b0\u1ee3c chia th\u00e0nh ba lo\u1ea1i ch\u00ednh: ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y (Primitive Data Type), ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu (Reference Data Type) v\u00e0 ki\u1ec3u d\u1eef li\u1ec7u kh\u00f4ng c\u1ed1 \u0111\u1ecbnh (Special Data Type). Trong \u0111\u00f3, ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y l\u00e0 n\u1ec1n t\u1ea3ng c\u01a1 b\u1ea3n, gi\u00fap l\u01b0u tr\u1eef c\u00e1c gi\u00e1 tr\u1ecb \u0111\u01a1n gi\u1ea3n v\u00e0 c\u00f3 hi\u1ec7u su\u1ea5t cao.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Kieu_du_lieu_nguyen_thuy_Primitive_Data_Type\"><\/span><strong>Ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y (Primitive Data Type)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Java cung c\u1ea5p <\/span><b>8 ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y<\/b><span style=\"font-weight: 400;\">, \u0111\u01b0\u1ee3c ph\u00e2n lo\u1ea1i d\u1ef1a tr\u00ean lo\u1ea1i gi\u00e1 tr\u1ecb ch\u00fang l\u01b0u tr\u1eef: s\u1ed1 nguy\u00ean, s\u1ed1 th\u1ef1c, k\u00fd t\u1ef1, v\u00e0 logic. C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y \u0111\u01b0\u1ee3c thi\u1ebft k\u1ebf t\u1ed1i \u01b0u \u0111\u1ec3 qu\u1ea3n l\u00fd b\u1ed9 nh\u1edb hi\u1ec7u qu\u1ea3 v\u00e0 t\u0103ng t\u1ed1c \u0111\u1ed9 x\u1eed l\u00fd.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 danh s\u00e1ch v\u00e0 chi ti\u1ebft c\u1ee7a t\u1eebng ki\u1ec3u:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Ki\u1ec3u d\u1eef li\u1ec7u<\/b><\/td>\n<td><b>Dung l\u01b0\u1ee3ng<\/b><\/td>\n<td><b>Ph\u1ea1m vi gi\u00e1 tr\u1ecb\u00a0<\/b><\/td>\n<td><b>Lo\u1ea1i gi\u00e1 tr\u1ecb\u00a0<\/b><\/td>\n<td><b>\u1ee8ng d\u1ee5ng ch\u00ednh<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>byte<\/b><\/td>\n<td><span style=\"font-weight: 400;\">1 byte (8 bits)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">-128 \u0111\u1ebfn 127<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1ed1 nguy\u00ean\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">L\u01b0u d\u1eef li\u1ec7u nh\u1ecf, t\u1ed1i \u01b0u b\u1ed9 nh\u1edb, x\u1eed l\u00fd file nh\u1ecb ph\u00e2n.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>short\u00a0<\/b><\/td>\n<td><span style=\"font-weight: 400;\">2 bytes (16 bits)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">-32,768 \u0111\u1ebfn 32,767<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1ed1 nguy\u00ean\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">\u1ee8ng d\u1ee5ng \u0111\u1ed3 h\u1ecda, x\u1eed l\u00fd d\u1eef li\u1ec7u nh\u1ecf g\u1ecdn.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>int<\/b><\/td>\n<td><span style=\"font-weight: 400;\">4 bytes (32 bits)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">-2,147,483,648 \u0111\u1ebfn 2,147,483,647<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1ed1 nguy\u00ean\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng ph\u1ed5 bi\u1ebfn, l\u01b0u ID, \u0111\u1ebfm s\u1ed1 l\u01b0\u1ee3ng.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>long<\/b><\/td>\n<td><span style=\"font-weight: 400;\">8 bytes (64 bits)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">-9,223,372,036,854,775,808 \u0111\u1ebfn 9,223,372,036,854,775,807<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1ed1 nguy\u00ean\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">X\u1eed l\u00fd s\u1ed1 l\u1edbn, \u1ee9ng d\u1ee5ng t\u00e0i ch\u00ednh, khoa h\u1ecdc.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>float\u00a0<\/b><\/td>\n<td><span style=\"font-weight: 400;\">4 bytes (32 bits)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">~ \u00b11.4E-45 \u0111\u1ebfn \u00b13.4E+38<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1ed1 th\u1ef1c d\u1ea5u ch\u1ea5m \u0111\u1ed9ng<\/span><\/td>\n<td><span style=\"font-weight: 400;\">X\u1eed l\u00fd s\u1ed1 th\u1ef1c, \u1ee9ng d\u1ee5ng khoa h\u1ecdc v\u1eeba ph\u1ea3i.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>double<\/b><\/td>\n<td><span style=\"font-weight: 400;\">8 bytes (64 bits)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">~ \u00b14.9E-324 \u0111\u1ebfn \u00b11.8E+308<\/span><\/td>\n<td><span style=\"font-weight: 400;\">S\u1ed1 th\u1ef1c d\u1ea5u ch\u1ea5m \u0111\u1ed9ng<\/span><\/td>\n<td><span style=\"font-weight: 400;\">T\u00ednh to\u00e1n ch\u00ednh x\u00e1c cao, x\u1eed l\u00fd d\u1eef li\u1ec7u l\u1edbn.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>char<\/b><\/td>\n<td><span style=\"font-weight: 400;\">2 bytes (16 bits)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">M\u1ed9t k\u00fd t\u1ef1 Unicode (<\/span><span style=\"font-weight: 400;\">\\u0000<\/span><span style=\"font-weight: 400;\"> \u0111\u1ebfn <\/span><span style=\"font-weight: 400;\">\\uFFFF<\/span><span style=\"font-weight: 400;\">)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">K\u00fd t\u1ef1\u00a0<\/span><\/td>\n<td><span style=\"font-weight: 400;\">L\u01b0u k\u00fd t\u1ef1, bi\u1ec3u t\u01b0\u1ee3ng, x\u1eed l\u00fd v\u0103n b\u1ea3n.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>boolean<\/b><\/td>\n<td><span style=\"font-weight: 400;\">1 bit (l\u01b0u 1 byte)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">true<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">false<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Gi\u00e1 tr\u1ecb logic<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Bi\u1ec3u di\u1ec5n logic trong \u0111i\u1ec1u ki\u1ec7n, v\u00f2ng l\u1eb7p.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 Ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">byte smallNumber = 127;<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">short shortNumber = 32000;<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">int integerNumber = 100000;<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">long largeNumber = 10000000000L;<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">float pi = 3.14f;<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">double preciseValue = 3.14159265359;<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">char initial = 'J';<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">boolean isJavaFun = true;<\/span><\/pre>\n<h2><span class=\"ez-toc-section\" id=\"Kieu_du_lieu_tham_chieu_Reference_Data_Type\"><\/span><strong>Ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu (Reference Data Type)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu (Reference Data Type) trong Java d\u00f9ng \u0111\u1ec3 l\u01b0u tr\u1eef \u0111\u1ecba ch\u1ec9 (tham chi\u1ebfu) c\u1ee7a c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng thay v\u00ec l\u01b0u tr\u1eef tr\u1ef1c ti\u1ebfp gi\u00e1 tr\u1ecb. C\u00e1c ki\u1ec3u tham chi\u1ebfu kh\u00f4ng \u0111\u01b0\u1ee3c \u0111\u1ecbnh ngh\u0129a s\u1eb5n trong Java m\u00e0 do ng\u01b0\u1eddi d\u00f9ng t\u1ef1 \u0111\u1ecbnh ngh\u0129a ho\u1eb7c \u0111\u01b0\u1ee3c cung c\u1ea5p th\u00f4ng qua c\u00e1c th\u01b0 vi\u1ec7n. Ch\u00fang bao g\u1ed3m <\/span><b>String<\/b><span style=\"font-weight: 400;\">, <\/span><b>Array<\/b><span style=\"font-weight: 400;\">, <\/span><b>Class<\/b><span style=\"font-weight: 400;\">, <\/span><b>Object<\/b><span style=\"font-weight: 400;\">, v\u00e0 <\/span><b>Interface<\/b><span style=\"font-weight: 400;\">.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu gi\u00fap Java h\u1ed7 tr\u1ee3 m\u1ea1nh m\u1ebd l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng, cho ph\u00e9p m\u00f4 h\u00ecnh h\u00f3a v\u00e0 qu\u1ea3n l\u00fd c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng ph\u1ee9c t\u1ea1p trong ch\u01b0\u01a1ng tr\u00ecnh.<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Lo\u1ea1i\u00a0<\/b><\/td>\n<td><b>T\u1ed5ng quan<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>String<\/b><\/td>\n<td><span style=\"font-weight: 400;\">\u0110\u1ea1i di\u1ec7n cho chu\u1ed7i k\u00fd t\u1ef1. L\u00e0 l\u1edbp b\u1ea5t bi\u1ebfn (immutable) trong g\u00f3i <\/span><span style=\"font-weight: 400;\">java.lang<\/span><span style=\"font-weight: 400;\">.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Array<\/b><\/td>\n<td><span style=\"font-weight: 400;\">M\u1ea3ng ch\u1ee9a c\u00e1c ph\u1ea7n t\u1eed c\u00f3 c\u00f9ng ki\u1ec3u d\u1eef li\u1ec7u, l\u01b0u tr\u1eef li\u00ean t\u1ee5c trong b\u1ed9 nh\u1edb. K\u00edch th\u01b0\u1edbc c\u1ed1 \u0111\u1ecbnh, truy c\u1eadp qua ch\u1ec9 s\u1ed1 (index).<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Class v\u00e0 Object<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Class l\u00e0 b\u1ea3n thi\u1ebft k\u1ebf (blueprint) ch\u1ee9a thu\u1ed9c t\u00ednh v\u00e0 ph\u01b0\u01a1ng th\u1ee9c, Object l\u00e0 th\u1ec3 hi\u1ec7n c\u1ee5 th\u1ec3 c\u1ee7a Class trong l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Interface<\/b><\/td>\n<td><span style=\"font-weight: 400;\">M\u00f4 t\u1ea3 t\u1eadp h\u1ee3p c\u00e1c ph\u01b0\u01a1ng th\u1ee9c m\u00e0 l\u1edbp ph\u1ea3i tri\u1ec3n khai. Ch\u1ec9 ch\u1ee9a khai b\u00e1o ph\u01b0\u01a1ng th\u1ee9c v\u00e0 h\u1eb1ng s\u1ed1, kh\u00f4ng c\u00f3 ph\u1ea7n th\u1ef1c thi.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5 ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">String message = \"Hello, Java!\";<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">String[] cities = {\"Hanoi\", \"Tokyo\", \"New York\"};<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu gi\u00fap Java h\u1ed7 tr\u1ee3 l\u1eadp tr\u00ecnh h\u01b0\u1edbng \u0111\u1ed1i t\u01b0\u1ee3ng m\u1ea1nh m\u1ebd v\u00e0 linh ho\u1ea1t. Hi\u1ec3u r\u00f5 v\u1ec1 ch\u00fang l\u00e0 b\u01b0\u1edbc quan tr\u1ecdng \u0111\u1ec3 x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng ph\u1ee9c t\u1ea1p, t\u1eeb x\u1eed l\u00fd chu\u1ed7i, qu\u1ea3n l\u00fd t\u1eadp h\u1ee3p d\u1eef li\u1ec7u, \u0111\u1ebfn m\u00f4 h\u00ecnh h\u00f3a c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng v\u00e0 h\u00e0nh vi trong th\u1ef1c t\u1ebf.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Kieu_du_lieu_khong_co_dinh_Special_Data_Type\"><\/span><strong>Ki\u1ec3u d\u1eef li\u1ec7u kh\u00f4ng c\u1ed1 \u0111\u1ecbnh (Special Data Type)<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Trong Java, b\u00ean c\u1ea1nh c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u c\u01a1 b\u1ea3n (primitive type) v\u00e0 ki\u1ec3u d\u1eef li\u1ec7u \u0111\u1ed1i t\u01b0\u1ee3ng (object type), c\u00f2n t\u1ed3n t\u1ea1i c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u kh\u00f4ng c\u1ed1 \u0111\u1ecbnh (Special Data Type) h\u1ed7 tr\u1ee3 l\u1eadp tr\u00ecnh vi\u00ean trong vi\u1ec7c vi\u1ebft m\u00e3 linh ho\u1ea1t v\u00e0 hi\u1ec7u qu\u1ea3 h\u01a1n.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 hai v\u00ed d\u1ee5 ti\u00eau bi\u1ec3u v\u1ec1 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u n\u00e0y:<\/span><\/p>\n<h3><b>var<\/b><b> (Java 10+): Ki\u1ec3u d\u1eef li\u1ec7u ng\u1ea7m \u0111\u1ecbnh<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">T\u1eeb Java 10, Java \u0111\u00e3 gi\u1edbi thi\u1ec7u t\u1eeb kh\u00f3a var \u0111\u1ec3 khai b\u00e1o ki\u1ec3u d\u1eef li\u1ec7u ng\u1ea7m \u0111\u1ecbnh. \u0110i\u1ec1u n\u00e0y cho ph\u00e9p tr\u00ecnh bi\u00ean d\u1ecbch t\u1ef1 x\u00e1c \u0111\u1ecbnh ki\u1ec3u d\u1eef li\u1ec7u d\u1ef1a tr\u00ean gi\u00e1 tr\u1ecb \u0111\u01b0\u1ee3c g\u00e1n, gi\u00fap m\u00e3 ng\u1eafn g\u1ecdn v\u00e0 d\u1ec5 \u0111\u1ecdc h\u01a1n.<\/span><\/p>\n<p><b>V\u00ed d\u1ee5:<\/b><\/p>\n<pre><span style=\"font-weight: 400;\">var message = \"Hello, Java\"; \/\/ Ki\u1ec3u d\u1eef li\u1ec7u c\u1ee7a message s\u1ebd l\u00e0 String<\/span>\r\n\r\n<span style=\"font-weight: 400;\">var number = 42; \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \/\/ Ki\u1ec3u d\u1eef li\u1ec7u c\u1ee7a number s\u1ebd l\u00e0 int<\/span>\r\n\r\n<span style=\"font-weight: 400;\">var list = List.of(1, 2, 3); \/\/ Ki\u1ec3u d\u1eef li\u1ec7u c\u1ee7a list s\u1ebd l\u00e0 List&lt;Integer&gt;<\/span><\/pre>\n<p><b>\u01afu \u0111i\u1ec3m:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Gi\u1ea3m thi\u1ec3u vi\u1ec7c l\u1eb7p l\u1ea1i khai b\u00e1o ki\u1ec3u d\u1eef li\u1ec7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">T\u0103ng t\u00ednh r\u00f5 r\u00e0ng khi s\u1eed d\u1ee5ng c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u ph\u1ee9c t\u1ea1p.<\/span><\/li>\n<\/ul>\n<p><b>H\u1ea1n ch\u1ebf:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Kh\u00f4ng th\u1ec3 s\u1eed d\u1ee5ng var \u0111\u1ec3 khai b\u00e1o bi\u1ebfn m\u00e0 kh\u00f4ng kh\u1edfi t\u1ea1o gi\u00e1 tr\u1ecb ngay l\u00fac \u0111\u1ea7u.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">C\u00f3 th\u1ec3 l\u00e0m m\u00e3 kh\u00f3 \u0111\u1ecdc n\u1ebfu kh\u00f4ng \u0111\u1eb7t t\u00ean bi\u1ebfn r\u00f5 r\u00e0ng.<\/span><\/li>\n<\/ul>\n<blockquote><p><em>\u0110\u1ecdc th\u00eam: <a href=\"https:\/\/itviec.com\/blog\/bien-trong-java\/\" target=\"_blank\" rel=\"noopener\"><strong>Bi\u1ebfn trong Java: Chi ti\u1ebft h\u01b0\u1edbng d\u1eabn s\u1eed d\u1ee5ng \u0111\u00fang c\u00e1ch<\/strong><\/a><\/em><\/p><\/blockquote>\n<h3><b>null<\/b><b>: \u0110\u1ea1i di\u1ec7n cho gi\u00e1 tr\u1ecb r\u1ed7ng<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">Trong Java, null l\u00e0 m\u1ed9t gi\u00e1 tr\u1ecb \u0111\u1eb7c bi\u1ec7t \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng \u0111\u1ec3 bi\u1ec3u th\u1ecb r\u1eb1ng m\u1ed9t bi\u1ebfn kh\u00f4ng tham chi\u1ebfu t\u1edbi b\u1ea5t k\u1ef3 \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0o. Ki\u1ec3u d\u1eef li\u1ec7u null c\u00f3 th\u1ec3 g\u00e1n cho b\u1ea5t k\u1ef3 ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu n\u00e0o (reference type).<\/span><\/p>\n<p><b>V\u00ed d\u1ee5:<\/b><\/p>\n<pre><span style=\"font-weight: 400;\">String name = null; \/\/ name kh\u00f4ng tham chi\u1ebfu t\u1edbi b\u1ea5t k\u1ef3 \u0111\u1ed1i t\u01b0\u1ee3ng n\u00e0o<\/span>\r\n\r\n<span style=\"font-weight: 400;\">Integer age = null; \/\/ age c\u0169ng kh\u00f4ng \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng null trong th\u1ef1c t\u1ebf:<\/span><\/p>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 ki\u1ec3m tra xem m\u1ed9t bi\u1ebfn \u0111\u00e3 \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o hay ch\u01b0a:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">if (name == null) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0System.out.println(\"Bi\u1ebfn name ch\u01b0a \u0111\u01b0\u1ee3c kh\u1edfi t\u1ea1o.\");<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 gi\u1ea3i ph\u00f3ng t\u00e0i nguy\u00ean b\u1eb1ng c\u00e1ch \u0111\u1eb7t tham chi\u1ebfu th\u00e0nh null:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">object = null; \/\/ Gi\u1ea3i ph\u00f3ng t\u00e0i nguy\u00ean \u0111\u1ec3 Garbage Collector thu h\u1ed3i<\/span><\/pre>\n<p><b>L\u01b0u \u00fd khi s\u1eed d\u1ee5ng null:<\/b><\/p>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">Tr\u00e1nh l\u1ed7i ph\u1ed5 bi\u1ebfn NullPointerException (NPE) b\u1eb1ng c\u00e1ch ki\u1ec3m tra null tr\u01b0\u1edbc khi s\u1eed d\u1ee5ng bi\u1ebfn.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng c\u00e1c c\u00f4ng c\u1ee5 h\u1ed7 tr\u1ee3 nh\u01b0 Optional (Java 8+) \u0111\u1ec3 x\u1eed l\u00fd gi\u00e1 tr\u1ecb r\u1ed7ng m\u1ed9t c\u00e1ch an to\u00e0n h\u01a1n.<\/span><\/li>\n<\/ul>\n<p><b>V\u00ed d\u1ee5 v\u1edbi Optional:<\/b><\/p>\n<pre><span style=\"font-weight: 400;\">Optional&lt;String&gt; optionalName = Optional.ofNullable(name);<\/span>\r\n\r\n<span style=\"font-weight: 400;\">optionalName.ifPresent(System.out::println);<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Nh\u00ecn chung, c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u kh\u00f4ng c\u1ed1 \u0111\u1ecbnh nh\u01b0 var v\u00e0 null gi\u00fap Java tr\u1edf n\u00ean m\u1ea1nh m\u1ebd v\u00e0 linh ho\u1ea1t h\u01a1n, nh\u01b0ng c\u1ea7n s\u1eed d\u1ee5ng ch\u00fang m\u1ed9t c\u00e1ch c\u1ea9n th\u1eadn \u0111\u1ec3 tr\u00e1nh l\u1ed7i v\u00e0 \u0111\u1ea3m b\u1ea3o m\u00e3 d\u1ec5 b\u1ea3o tr\u00ec.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"So_sanh_giua_kieu_du_lieu_nguyen_thuy_va_kieu_du_lieu_tham_chieu\"><\/span><strong>So s\u00e1nh gi\u1eefa ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y v\u00e0 ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">\u0110\u1ec3 c\u00f3 c\u00e1i nh\u00ecn r\u00f5 h\u01a1n v\u1ec1 s\u1ef1 kh\u00e1c nhau gi\u1eefa hai ki\u1ec3u d\u1eef li\u1ec7u n\u00e0y, ch\u00fang ta s\u1ebd ph\u00e2n t\u00edch th\u00f4ng qua b\u1ea3ng sau:<\/span><\/p>\n<table>\n<tbody>\n<tr>\n<td><b>Ti\u00eau ch\u00ed<\/b><\/td>\n<td><b>Ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y<\/b><\/td>\n<td><b>Ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu\u00a0<\/b><\/td>\n<\/tr>\n<tr>\n<td><b>\u0110\u1ecbnh ngh\u0129a\u00a0<\/b><\/td>\n<td><span style=\"font-weight: 400;\">L\u00e0 ki\u1ec3u d\u1eef li\u1ec7u c\u01a1 b\u1ea3n nh\u1eb5m l\u01b0u tr\u1eef gi\u00e1 tr\u1ecb \u0111\u01a1n (s\u1ed1 nguy\u00ean, s\u1ed1 th\u1ef1c, k\u00fd t\u1ef1, boolean,&#8230;)<\/span><\/td>\n<td><span style=\"font-weight: 400;\">L\u00e0 ki\u1ec3u l\u01b0u tr\u1eef tham chi\u1ebfu \u0111\u1ebfn \u0111\u1ed1i t\u01b0\u1ee3ng ho\u1eb7c m\u1ea3ng trong b\u1ed9 nh\u1edb.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>K\u00edch th\u01b0\u1edbc<\/b><\/td>\n<td><span style=\"font-weight: 400;\">\u0110\u1ecbnh s\u1eb5n, ph\u1ee5 thu\u1ed9c v\u00e0o lo\u1ea1i ki\u1ec3u (\u0111\u01b0\u1ee3c quy \u0111\u1ecbnh theo JVM).<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Thay \u0111\u1ed5i ph\u1ee5 thu\u1ed9c v\u00e0o \u0111\u1ed1i t\u01b0\u1ee3ng ho\u1eb7c m\u1ea3ng m\u00e0 tham chi\u1ebfu \u0111\u1ebfn.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>L\u01b0u tr\u1eef<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Trong stack memory.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Trong heap memory (tham chi\u1ebfu \u0111\u01b0\u1ee3c l\u01b0u trong stack).<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Gi\u00e1 tr\u1ecb m\u1eb7c \u0111\u1ecbnh\u00a0<\/b><\/td>\n<td><span style=\"font-weight: 400;\">0 (s\u1ed1), false (boolean), \\u0000 (char).<\/span><\/td>\n<td><span style=\"font-weight: 400;\">null.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>Hi\u1ec7u su\u1ea5t<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Hi\u1ec7u su\u1ea5t cao, truy c\u1eadp nhanh.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Ch\u1eadm h\u01a1n do c\u1ea7n tham chi\u1ebfu \u0111\u1ebfn heap memory.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>\u0110\u1ed1i t\u01b0\u1ee3ng h\u00f3a<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng th\u1ec3, nh\u01b0ng c\u00f3 th\u1ec3 bao b\u1ecdc trong wrapper class (\u0111\u1ec3 tr\u1edf th\u00e0nh tham chi\u1ebfu).<\/span><\/td>\n<td><span style=\"font-weight: 400;\">L\u00e0 c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng trong Java, c\u00f3 th\u1ec3 s\u1eed d\u1ee5ng t\u1ef1 do.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>\u01afu \u0111i\u1ec3m<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Hi\u1ec7u su\u1ea5t cao do truy c\u1eadp tr\u1ef1c ti\u1ebfp trong stack memory.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng d\u1ec5 d\u00e0ng, th\u00edch h\u1ee3p cho c\u00e1c t\u00e1c v\u1ee5 t\u00ednh to\u00e1n c\u01a1 b\u1ea3n.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Linh ho\u1ea1t, c\u00f3 th\u1ec3 t\u00f9y ch\u1ec9nh \u0111\u1ed1i t\u01b0\u1ee3ng theo nhu c\u1ea7u.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">H\u1ed7 tr\u1ee3 nhi\u1ec1u ph\u01b0\u01a1ng th\u1ee9c \u0111\u1ec3 thao t\u00e1c v\u1edbi d\u1eef li\u1ec7u.<\/span><\/td>\n<\/tr>\n<tr>\n<td><b>H\u1ea1n ch\u1ebf<\/b><\/td>\n<td><span style=\"font-weight: 400;\">Kh\u00f4ng c\u00f3 c\u00e1c ph\u01b0\u01a1ng th\u1ee9c k\u00e8m theo.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">Kh\u00f4ng linh ho\u1ea1t trong c\u00e1c thao t\u00e1c ph\u1ee9c t\u1ea1p nh\u01b0 qu\u1ea3n l\u00fd t\u1eadp d\u1eef li\u1ec7u.<\/span><\/td>\n<td><span style=\"font-weight: 400;\">Hi\u1ec7u su\u1ea5t th\u1ea5p h\u01a1n do truy c\u1eadp heap memory.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">D\u1ec5 g\u00e2y l\u1ed7i NullPointerException n\u1ebfu th\u1eed truy c\u1eadp tham chi\u1ebfu null.<\/span><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h2><span class=\"ez-toc-section\" id=\"Cach_su_dung_cac_kieu_du_lieu_trong_Java\"><\/span><strong>C\u00e1ch s\u1eed d\u1ee5ng c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">D\u01b0\u1edbi \u0111\u00e2y l\u00e0 c\u00e1ch s\u1eed d\u1ee5ng, khai b\u00e1o, kh\u1edfi t\u1ea1o, v\u00e0 chuy\u1ec3n \u0111\u1ed5i ki\u1ec3u d\u1eef li\u1ec7u trong Java, k\u00e8m theo c\u00e1c v\u00ed d\u1ee5 th\u1ef1c t\u1ebf cho t\u1eebng ki\u1ec3u d\u1eef li\u1ec7u trong Java l\u00e0 ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y v\u00e0 ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu.<\/span><\/p>\n<h3><b> C\u00e1ch khai b\u00e1o v\u00e0 kh\u1edfi t\u1ea1o ki\u1ec3u d\u1eef li\u1ec7u<\/b><\/h3>\n<p><span style=\"font-weight: 400;\">C\u00fa ph\u00e1p:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">&lt;ki\u1ec3u_d\u1eef_li\u1ec7u&gt; &lt;t\u00ean_bi\u1ebfn&gt; = &lt;gi\u00e1_tr\u1ecb_kh\u1edfi_t\u1ea1o&gt;;<\/span><\/pre>\n<p><b>V\u00ed d\u1ee5:<\/b><\/p>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u nguy\u00ean th\u1ee7y:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">int age = 25;\u00a0 \u00a0 \u00a0 \u00a0 \/\/ Khai b\u00e1o v\u00e0 kh\u1edfi t\u1ea1o bi\u1ebfn ki\u1ec3u int<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">double salary = 5000.75; \/\/ Khai b\u00e1o bi\u1ebfn ki\u1ec3u double<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">char grade = 'A';\u00a0 \u00a0 \/\/ Khai b\u00e1o bi\u1ebfn ki\u1ec3u char<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">boolean isActive = true; \/\/ Khai b\u00e1o bi\u1ebfn ki\u1ec3u boolean<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u tham chi\u1ebfu:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">String name = \"John Doe\"; \/\/ Khai b\u00e1o bi\u1ebfn ki\u1ec3u String<\/span><\/pre>\n<pre><span style=\"font-weight: 400;\">int[] numbers = {1, 2, 3}; \/\/ Khai b\u00e1o m\u1ea3ng ki\u1ec3u int<\/span><\/pre>\n<h3><b> Chuy\u1ec3n \u0111\u1ed5i ki\u1ec3u d\u1eef li\u1ec7u (Type Casting)<\/b><\/h3>\n<h4><b>Chuy\u1ec3n \u0111\u1ed5i ng\u1ea7m \u0111\u1ecbnh (Implicit Casting)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">Java t\u1ef1 \u0111\u1ed9ng chuy\u1ec3n \u0111\u1ed5i t\u1eeb ki\u1ec3u nh\u1ecf h\u01a1n sang ki\u1ec3u l\u1edbn h\u01a1n khi kh\u00f4ng g\u00e2y m\u1ea5t m\u00e1t d\u1eef li\u1ec7u.<\/span><\/p>\n<p><b>V\u00ed d\u1ee5:<\/b><\/p>\n<pre><span style=\"font-weight: 400;\">int myInt = 9;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">double myDouble = myInt; \/\/ Chuy\u1ec3n \u0111\u1ed5i ng\u1ea7m \u0111\u1ecbnh t\u1eeb int sang double<\/span>\r\n\r\n<span style=\"font-weight: 400;\">System.out.println(myDouble); \/\/ Output: 9.0<\/span><\/pre>\n<h4><b>Chuy\u1ec3n \u0111\u1ed5i t\u01b0\u1eddng minh (Explicit Casting)<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">C\u1ea7n th\u1ef1c hi\u1ec7n t\u01b0\u1eddng minh khi chuy\u1ec3n t\u1eeb ki\u1ec3u l\u1edbn h\u01a1n sang ki\u1ec3u nh\u1ecf h\u01a1n \u0111\u1ec3 tr\u00e1nh m\u1ea5t m\u00e1t d\u1eef li\u1ec7u.<\/span><\/p>\n<p><b>V\u00ed d\u1ee5:<\/b><\/p>\n<pre><span style=\"font-weight: 400;\">double myDouble = 9.78;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">int myInt = (int) myDouble; \/\/ Chuy\u1ec3n \u0111\u1ed5i t\u01b0\u1eddng minh t\u1eeb double sang int<\/span>\r\n\r\n<span style=\"font-weight: 400;\">System.out.println(myInt); \/\/ Output: 9<\/span><\/pre>\n<h3><b> X\u1eed l\u00fd l\u1ed7i khi s\u1eed d\u1ee5ng sai ki\u1ec3u d\u1eef li\u1ec7u<\/b><\/h3>\n<h4><strong>L\u1ed7i compile-time<\/strong><\/h4>\n<p><span style=\"font-weight: 400;\">X\u1ea3y ra khi khai b\u00e1o sai ki\u1ec3u d\u1eef li\u1ec7u ho\u1eb7c g\u00e1n gi\u00e1 tr\u1ecb kh\u00f4ng ph\u00f9 h\u1ee3p.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">int number = \"Hello\"; \/\/ L\u1ed7i: Kh\u00f4ng th\u1ec3 g\u00e1n String cho int<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">C\u00e1ch x\u1eed l\u00fd: Ki\u1ec3m tra v\u00e0 s\u1eeda \u0111\u00fang ki\u1ec3u d\u1eef li\u1ec7u.<\/span><\/p>\n<h4><b>L\u1ed7i runtime<\/b><\/h4>\n<p><span style=\"font-weight: 400;\">X\u1ea3y ra khi chuy\u1ec3n \u0111\u1ed5i ki\u1ec3u kh\u00f4ng h\u1ee3p l\u1ec7. V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">Object obj = \"Java\";<\/span>\r\n\r\n<span style=\"font-weight: 400;\">int num = (int) obj; \/\/ L\u1ed7i: ClassCastException<\/span><\/pre>\n<p><b>C\u00e1ch x\u1eed l\u00fd<\/b><\/p>\n<p><span style=\"font-weight: 400;\">S\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">instanceof<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 ki\u1ec3m tra ki\u1ec3u tr\u01b0\u1edbc khi chuy\u1ec3n \u0111\u1ed5i.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">if (obj instanceof Integer) {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0int num = (int) obj;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">} else {<\/span>\r\n\r\n<span style=\"font-weight: 400;\">\u00a0\u00a0\u00a0\u00a0System.out.println(\"Chuy\u1ec3n \u0111\u1ed5i kh\u00f4ng h\u1ee3p l\u1ec7!\");<\/span>\r\n\r\n<span style=\"font-weight: 400;\">}<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">Hi\u1ec3u v\u00e0 s\u1eed d\u1ee5ng \u0111\u00fang c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java kh\u00f4ng ch\u1ec9 gi\u00fap ch\u01b0\u01a1ng tr\u00ecnh ch\u1ea1y hi\u1ec7u qu\u1ea3 m\u00e0 c\u00f2n gi\u1ea3m thi\u1ec3u l\u1ed7i. N\u1eafm v\u1eefng c\u00e1ch khai b\u00e1o, kh\u1edfi t\u1ea1o, v\u00e0 chuy\u1ec3n \u0111\u1ed5i ki\u1ec3u d\u1eef li\u1ec7u l\u00e0 k\u1ef9 n\u0103ng c\u1ea7n thi\u1ebft cho m\u1ecdi l\u1eadp tr\u00ecnh vi\u00ean Java.<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Luu_y_khi_lam_viec_voi_cac_kieu_du_lieu_trong_Java\"><\/span><strong>L\u01b0u \u00fd khi l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Java cung c\u1ea5p nhi\u1ec1u ki\u1ec3u d\u1eef li\u1ec7u \u0111\u1ec3 \u0111\u00e1p \u1ee9ng c\u00e1c nhu c\u1ea7u kh\u00e1c nhau, t\u1eeb c\u00e1c ki\u1ec3u nguy\u00ean th\u1ee7y (primitive) nh\u01b0 <\/span><span style=\"font-weight: 400;\">int<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">float<\/span><span style=\"font-weight: 400;\">, \u0111\u1ebfn c\u00e1c ki\u1ec3u tham chi\u1ebfu (reference) nh\u01b0 <\/span><span style=\"font-weight: 400;\">String<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c c\u00e1c l\u1edbp \u0111\u1ed1i t\u01b0\u1ee3ng. Khi l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u n\u00e0y, c\u00f3 m\u1ed9t s\u1ed1 l\u01b0u \u00fd quan tr\u1ecdng \u0111\u1ec3 \u0111\u1ea3m b\u1ea3o hi\u1ec7u qu\u1ea3 v\u00e0 \u0111\u1ed9 ch\u00ednh x\u00e1c trong l\u1eadp tr\u00ecnh:<\/span><\/p>\n<h3><strong>Hi\u1ec7u qu\u1ea3 b\u1ed9 nh\u1edb v\u00e0 t\u1ed1i \u01b0u h\u00f3a<\/strong><\/h3>\n<ul>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>Ch\u1ecdn ki\u1ec3u d\u1eef li\u1ec7u ph\u00f9 h\u1ee3p:<\/b><span style=\"font-weight: 400;\"> Java cung c\u1ea5p c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u v\u1edbi k\u00edch th\u01b0\u1edbc c\u1ed1 \u0111\u1ecbnh, nh\u01b0 <\/span><span style=\"font-weight: 400;\">byte<\/span><span style=\"font-weight: 400;\"> (8 bit), <\/span><span style=\"font-weight: 400;\">short<\/span><span style=\"font-weight: 400;\"> (16 bit), <\/span><span style=\"font-weight: 400;\">int<\/span><span style=\"font-weight: 400;\"> (32 bit), v\u00e0 <\/span><span style=\"font-weight: 400;\">long<\/span><span style=\"font-weight: 400;\"> (64 bit). S\u1eed d\u1ee5ng ki\u1ec3u d\u1eef li\u1ec7u nh\u1ecf h\u01a1n n\u1ebfu bi\u1ebft tr\u01b0\u1edbc ph\u1ea1m vi gi\u00e1 tr\u1ecb, nh\u01b0 d\u00f9ng <\/span><span style=\"font-weight: 400;\">byte<\/span><span style=\"font-weight: 400;\"> cho c\u00e1c gi\u00e1 tr\u1ecb nh\u1ecf thay v\u00ec <\/span><span style=\"font-weight: 400;\">int<\/span><span style=\"font-weight: 400;\">, gi\u00fap ti\u1ebft ki\u1ec7m b\u1ed9 nh\u1edb.<\/span><\/li>\n<li style=\"font-weight: 400;\" aria-level=\"1\"><b>S\u1eed d\u1ee5ng c\u00e1c ki\u1ec3u nguy\u00ean th\u1ee7y thay v\u00ec \u0111\u1ed1i t\u01b0\u1ee3ng wrapper:<\/b><span style=\"font-weight: 400;\"> C\u00e1c l\u1edbp nh\u01b0 <\/span><span style=\"font-weight: 400;\">Integer<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">Double<\/span><span style=\"font-weight: 400;\"> c\u00f3 th\u00eam overhead do ch\u1ee9a c\u00e1c thu\u1ed9c t\u00ednh v\u00e0 ph\u01b0\u01a1ng th\u1ee9c. V\u00ec v\u1eady, khi kh\u00f4ng c\u1ea7n \u0111\u1ebfn t\u00ednh n\u0103ng b\u1ed5 sung, h\u00e3y s\u1eed d\u1ee5ng ki\u1ec3u nguy\u00ean th\u1ee7y (<\/span><span style=\"font-weight: 400;\">int<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">double<\/span><span style=\"font-weight: 400;\">).<\/span><\/li>\n<\/ul>\n<h3><strong>C\u1ea9n tr\u1ecdng khi s\u1eed d\u1ee5ng ki\u1ec3u float v\u00e0 double<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">C\u00e1c ki\u1ec3u <\/span><span style=\"font-weight: 400;\">float<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">double<\/span><span style=\"font-weight: 400;\"> s\u1eed d\u1ee5ng bi\u1ec3u di\u1ec5n d\u1ea5u ph\u1ea9y \u0111\u1ed9ng (floating-point), d\u1eabn \u0111\u1ebfn c\u00e1c v\u1ea5n \u0111\u1ec1 v\u1ec1 \u0111\u1ed9 ch\u00ednh x\u00e1c. <\/span><span style=\"font-weight: 400;\">C\u00e1c ph\u00e9p to\u00e1n s\u1ed1 h\u1ecdc v\u1edbi <\/span><span style=\"font-weight: 400;\">float<\/span><span style=\"font-weight: 400;\"> v\u00e0 <\/span><span style=\"font-weight: 400;\">double<\/span><span style=\"font-weight: 400;\"> c\u00f3 th\u1ec3 kh\u00f4ng ch\u00ednh x\u00e1c ho\u00e0n to\u00e0n do c\u00e1ch l\u01b0u tr\u1eef nh\u1ecb ph\u00e2n.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">V\u00ed d\u1ee5:<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">System.out.println(0.1 + 0.2); \/\/ K\u1ebft qu\u1ea3: 0.30000000000000004<\/span><\/pre>\n<p><b>Gi\u1ea3i ph\u00e1p:<\/b><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">N\u1ebfu y\u00eau c\u1ea7u \u0111\u1ed9 ch\u00ednh x\u00e1c cao, nh\u01b0 trong t\u00ednh to\u00e1n ti\u1ec1n t\u1ec7, h\u00e3y s\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">BigDecimal<\/span><span style=\"font-weight: 400;\"> thay v\u00ec <\/span><span style=\"font-weight: 400;\">float<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">double<\/span><span style=\"font-weight: 400;\">.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Khi so s\u00e1nh hai s\u1ed1 d\u1ea5u ph\u1ea9y \u0111\u1ed9ng, h\u00e3y s\u1eed d\u1ee5ng kho\u1ea3ng sai s\u1ed1 (<\/span><span style=\"font-weight: 400;\">epsilon<\/span><span style=\"font-weight: 400;\">) thay v\u00ec so s\u00e1nh tr\u1ef1c ti\u1ebfp.<\/span><\/li>\n<\/ul>\n<h3><strong>\u0110\u1eb7c \u0111i\u1ec3m c\u1ee7a ki\u1ec3u d\u1eef li\u1ec7u b\u1ea5t bi\u1ebfn (Immutable Data Type)<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">M\u1ed9t s\u1ed1 ki\u1ec3u d\u1eef li\u1ec7u trong Java, nh\u01b0 <\/span><span style=\"font-weight: 400;\">String<\/span><span style=\"font-weight: 400;\"> v\u00e0 c\u00e1c l\u1edbp trong <\/span><span style=\"font-weight: 400;\">java.time<\/span><span style=\"font-weight: 400;\">, l\u00e0 b\u1ea5t bi\u1ebfn (immutable):<\/span><\/p>\n<p><b>\u0110\u1eb7c \u0111i\u1ec3m:<\/b><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">Gi\u00e1 tr\u1ecb c\u1ee7a ch\u00fang kh\u00f4ng th\u1ec3 thay \u0111\u1ed5i sau khi \u0111\u01b0\u1ee3c t\u1ea1o.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">B\u1ea5t k\u1ef3 thao t\u00e1c n\u00e0o thay \u0111\u1ed5i gi\u00e1 tr\u1ecb \u0111\u1ec1u t\u1ea1o ra m\u1ed9t \u0111\u1ed1i t\u01b0\u1ee3ng m\u1edbi.<\/span><\/li>\n<\/ul>\n<p><b>L\u1ee3i \u00edch:<\/b><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">D\u1ec5 d\u00e0ng s\u1eed d\u1ee5ng trong c\u00e1c m\u00f4i tr\u01b0\u1eddng \u0111a lu\u1ed3ng v\u00ec kh\u00f4ng c\u1ea7n \u0111\u1ed3ng b\u1ed9 h\u00f3a (thread-safe).<\/span><\/li>\n<li><span style=\"font-weight: 400;\">H\u1ea1n ch\u1ebf l\u1ed7i khi chia s\u1ebb d\u1eef li\u1ec7u gi\u1eefa c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng.<\/span><\/li>\n<\/ul>\n<p><b>L\u01b0u \u00fd v\u1ec1 hi\u1ec7u n\u0103ng:<\/b><\/p>\n<ul>\n<li><span style=\"font-weight: 400;\">Vi\u1ec7c t\u1ea1o nhi\u1ec1u \u0111\u1ed1i t\u01b0\u1ee3ng m\u1edbi khi thao t\u00e1c v\u1edbi c\u00e1c ki\u1ec3u b\u1ea5t bi\u1ebfn (nh\u01b0 n\u1ed1i chu\u1ed7i v\u1edbi <\/span><span style=\"font-weight: 400;\">String<\/span><span style=\"font-weight: 400;\">) c\u00f3 th\u1ec3 l\u00e0m gi\u1ea3m hi\u1ec7u n\u0103ng. S\u1eed d\u1ee5ng <\/span><span style=\"font-weight: 400;\">StringBuilder<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c <\/span><span style=\"font-weight: 400;\">StringBuffer<\/span><span style=\"font-weight: 400;\"> \u0111\u1ec3 gi\u1ea3m overhead.<\/span><\/li>\n<li><span style=\"font-weight: 400;\">Khi l\u00e0m vi\u1ec7c v\u1edbi c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java, hi\u1ec3u r\u00f5 \u0111\u1eb7c \u0111i\u1ec3m v\u00e0 c\u00e1ch s\u1eed d\u1ee5ng ch\u00fang kh\u00f4ng ch\u1ec9 gi\u00fap t\u1ed1i \u01b0u h\u00f3a hi\u1ec7u n\u0103ng m\u00e0 c\u00f2n gi\u1ea3m thi\u1ec3u l\u1ed7i trong \u1ee9ng d\u1ee5ng.<\/span><\/li>\n<\/ul>\n<h2><span class=\"ez-toc-section\" id=\"Cac_cau_hoi_thuong_gap_ve_cac_kieu_du_lieu_trong_Java\"><\/span><strong>C\u00e1c c\u00e2u h\u1ecfi th\u01b0\u1eddng g\u1eb7p v\u1ec1 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<h3><strong>T\u1ea1i sao Java s\u1eed d\u1ee5ng ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y thay v\u00ec t\u1ea5t c\u1ea3 l\u00e0 \u0111\u1ed1i t\u01b0\u1ee3ng?<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">Ki\u1ec3u nguy\u00ean th\u1ee7y gi\u00fap Java hi\u1ec7u qu\u1ea3 h\u01a1n v\u1ec1 m\u1eb7t hi\u1ec7u su\u1ea5t v\u00e0 b\u1ed9 nh\u1edb, v\u00ec ch\u00fang l\u01b0u tr\u1eef tr\u1ef1c ti\u1ebfp gi\u00e1 tr\u1ecb v\u00e0 kh\u00f4ng y\u00eau c\u1ea7u x\u1eed l\u00fd th\u00eam nh\u01b0 \u0111\u1ed1i t\u01b0\u1ee3ng<\/span><\/p>\n<h3><strong>Khi n\u00e0o n\u00ean s\u1eed d\u1ee5ng Wrapper Classes?<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">Wrapper Classes \u0111\u01b0\u1ee3c s\u1eed d\u1ee5ng khi c\u1ea7n l\u01b0u tr\u1eef ki\u1ec3u nguy\u00ean th\u1ee7y trong c\u00e1c c\u1ea5u tr\u00fac d\u1eef li\u1ec7u y\u00eau c\u1ea7u \u0111\u1ed1i t\u01b0\u1ee3ng, nh\u01b0 <\/span><span style=\"font-weight: 400;\">ArrayList<\/span><span style=\"font-weight: 400;\"> ho\u1eb7c khi c\u1ea7n s\u1eed d\u1ee5ng c\u00e1c ph\u01b0\u01a1ng th\u1ee9c ti\u1ec7n \u00edch \u0111i k\u00e8m.<\/span><\/p>\n<h3><strong>L\u00e0m th\u1ebf n\u00e0o \u0111\u1ec3 qu\u1ea3n l\u00fd vi\u1ec7c \u00e9p ki\u1ec3u (type casting) gi\u1eefa c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java?<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">\u00c9p ki\u1ec3u t\u01b0\u1eddng minh (Explicit Casting): Khi chuy\u1ec3n t\u1eeb ki\u1ec3u l\u1edbn h\u01a1n sang ki\u1ec3u nh\u1ecf h\u01a1n.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">double d = 9.8;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">int i = (int) d; \/\/ K\u1ebft qu\u1ea3 l\u00e0 9<\/span><\/pre>\n<p><span style=\"font-weight: 400;\">\u00c9p ki\u1ec3u ng\u1ea7m \u0111\u1ecbnh (Implicit Casting): Khi chuy\u1ec3n t\u1eeb ki\u1ec3u nh\u1ecf h\u01a1n sang ki\u1ec3u l\u1edbn h\u01a1n.<\/span><\/p>\n<pre><span style=\"font-weight: 400;\">int i = 10;<\/span>\r\n\r\n<span style=\"font-weight: 400;\">double d = i; \/\/ Kh\u00f4ng c\u1ea7n \u00e9p ki\u1ec3u<\/span><\/pre>\n<p><span style=\"font-weight: 400;\"><strong>L\u01b0u \u00fd:<\/strong> \u00c9p ki\u1ec3u kh\u00f4ng an to\u00e0n c\u00f3 th\u1ec3 g\u00e2y m\u1ea5t d\u1eef li\u1ec7u ho\u1eb7c l\u1ed7i runtime.<\/span><\/p>\n<h3><strong>\u0110i\u1ec1u g\u00ec x\u1ea3y ra khi b\u1ea1n v\u01b0\u1ee3t qu\u00e1 ph\u1ea1m vi c\u1ee7a ki\u1ec3u d\u1eef li\u1ec7u, ch\u1eb3ng h\u1ea1n nh\u01b0 khi gi\u00e1 tr\u1ecb c\u1ee7a int l\u1edbn h\u01a1n 2,147,483,647?<\/strong><\/h3>\n<p><span style=\"font-weight: 400;\">X\u1ea3y ra hi\u1ec7n t\u01b0\u1ee3ng <\/span><b>tr\u00e0n s\u1ed1<\/b><span style=\"font-weight: 400;\"> (overflow) v\u00e0 gi\u00e1 tr\u1ecb s\u1ebd quay v\u00f2ng l\u1ea1i t\u1eeb gi\u00e1 tr\u1ecb nh\u1ecf nh\u1ea5t (-2,147,483,648).<\/span><\/p>\n<h2><span class=\"ez-toc-section\" id=\"Tong_ket\"><\/span><strong>T\u1ed5ng k\u1ebft<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p><span style=\"font-weight: 400;\">Hi\u1ec3u r\u00f5 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java l\u00e0 b\u01b0\u1edbc quan tr\u1ecdng \u0111\u1ec3 x\u00e2y d\u1ef1ng n\u1ec1n t\u1ea3ng v\u1eefng ch\u1eafc trong l\u1eadp tr\u00ecnh. Vi\u1ec7c ch\u1ecdn \u0111\u00fang ki\u1ec3u d\u1eef li\u1ec7u kh\u00f4ng ch\u1ec9 gi\u00fap t\u1ed1i \u01b0u h\u00f3a hi\u1ec7u su\u1ea5t m\u00e0 c\u00f2n t\u0103ng c\u01b0\u1eddng t\u00ednh r\u00f5 r\u00e0ng v\u00e0 kh\u1ea3 n\u0103ng b\u1ea3o tr\u00ec c\u1ee7a m\u00e3 ngu\u1ed3n. T\u1eeb c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u nguy\u00ean th\u1ee7y (primitive) nh\u01b0 <\/span><span style=\"font-weight: 400;\">int<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">double<\/span><span style=\"font-weight: 400;\">, <\/span><span style=\"font-weight: 400;\">char<\/span><span style=\"font-weight: 400;\"> \u0111\u1ebfn c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u tham chi\u1ebfu (reference) nh\u01b0 <\/span><span style=\"font-weight: 400;\">String<\/span><span style=\"font-weight: 400;\"> hay c\u00e1c \u0111\u1ed1i t\u01b0\u1ee3ng, m\u1ed7i lo\u1ea1i \u0111\u1ec1u c\u00f3 \u1ee9ng d\u1ee5ng ri\u00eang ph\u00f9 h\u1ee3p v\u1edbi t\u1eebng t\u00ecnh hu\u1ed1ng.<\/span><\/p>\n<p><span style=\"font-weight: 400;\">L\u00e0 m\u1ed9t ng\u00f4n ng\u1eef m\u1ea1nh m\u1ebd v\u00e0 linh ho\u1ea1t, Java cung c\u1ea5p \u0111\u1ea7y \u0111\u1ee7 c\u00f4ng c\u1ee5 \u0111\u1ec3 l\u1eadp tr\u00ecnh vi\u00ean x\u1eed l\u00fd d\u1eef li\u1ec7u hi\u1ec7u qu\u1ea3. V\u00ec v\u1eady, h\u00e3y t\u1eadn d\u1ee5ng t\u1ed1t c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u, \u0111\u1ed3ng th\u1eddi n\u1eafm v\u1eefng c\u00e1ch ho\u1ea1t \u0111\u1ed9ng c\u1ee7a ch\u00fang \u0111\u1ec3 vi\u1ebft m\u00e3 kh\u00f4ng ch\u1ec9 ch\u00ednh x\u00e1c m\u00e0 c\u00f2n t\u1ed1i \u01b0u v\u00e0 d\u1ec5 m\u1edf r\u1ed9ng. Vi\u1ec7c n\u00e0y s\u1ebd gi\u00fap b\u1ea1n tr\u1edf th\u00e0nh m\u1ed9t l\u1eadp tr\u00ecnh vi\u00ean Java chuy\u00ean nghi\u1ec7p, s\u1eb5n s\u00e0ng \u0111\u1ed1i m\u1eb7t v\u1edbi c\u00e1c th\u1eed th\u00e1ch trong ph\u00e1t tri\u1ec3n ph\u1ea7n m\u1ec1m.<\/span><\/p>\n<blockquote><p><em>\u0110\u1ecdc th\u00eam: <a href=\"https:\/\/itviec.com\/blog\/cau-hoi-phong-van-java\/\" target=\"_blank\" rel=\"noopener\"><strong>Top 40+ c\u00e2u h\u1ecfi ph\u1ecfng v\u1ea5n Java nh\u1ea5t \u0111\u1ecbnh c\u00f3 trong bu\u1ed5i ph\u1ecfng v\u1ea5n<\/strong><\/a><\/em><\/p><\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>Ki\u1ec3u d\u1eef li\u1ec7u \u0111\u00f3ng vai tr\u00f2 quan tr\u1ecdng trong vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng Java, gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean x\u00e1c \u0111\u1ecbnh v\u00e0 qu\u1ea3n l\u00fd hi\u1ec7u qu\u1ea3 c\u00e1ch l\u01b0u tr\u1eef, x\u1eed l\u00fd d\u1eef li\u1ec7u trong ch\u01b0\u01a1ng tr\u00ecnh. Trong Java, vi\u1ec7c l\u1ef1a ch\u1ecdn \u0111\u00fang ki\u1ec3u d\u1eef li\u1ec7u kh\u00f4ng ch\u1ec9 gi\u00fap c\u1ea3i thi\u1ec7n hi\u1ec7u n\u0103ng m\u00e0 c\u00f2n [&hellip;]<\/p>\n","protected":false},"author":203,"featured_media":84281,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_gspb_post_css":"","footnotes":""},"categories":[109],"tags":[],"class_list":["post-84251","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-chuyen-mon-it"],"blocksy_meta":[],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.8 (Yoast SEO v27.7) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java A-Z: \u0110\u1ecbnh ngh\u0129a v\u00e0 C\u00e1ch s\u1eed d\u1ee5ng - ITviec Blog<\/title>\n<meta name=\"description\" content=\"Hi\u1ec3u r\u00f5 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java t\u1eeb ki\u1ec3u nguy\u00ean th\u1ee7y \u0111\u1ebfn ki\u1ec3u ph\u1ee9c t\u1ea1p, c\u00f9ng c\u00e1c v\u00ed d\u1ee5 gi\u00fap s\u1eed d\u1ee5ng ch\u00fang m\u1ed9t c\u00e1ch linh ho\u1ea1t v\u00e0 ch\u00ednh x\u00e1c.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/\" \/>\n<meta property=\"og:locale\" content=\"vi_VN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java A-Z: \u0110\u1ecbnh ngh\u0129a v\u00e0 C\u00e1ch s\u1eed d\u1ee5ng\" \/>\n<meta property=\"og:description\" content=\"Ki\u1ec3u d\u1eef li\u1ec7u \u0111\u00f3ng vai tr\u00f2 quan tr\u1ecdng trong vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng Java, gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean x\u00e1c \u0111\u1ecbnh v\u00e0 qu\u1ea3n l\u00fd hi\u1ec7u qu\u1ea3 c\u00e1ch l\u01b0u tr\u1eef, x\u1eed l\u00fd d\u1eef li\u1ec7u\" \/>\n<meta property=\"og:url\" content=\"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/\" \/>\n<meta property=\"og:site_name\" content=\"ITviec Blog\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ITviec\" \/>\n<meta property=\"article:published_time\" content=\"2025-01-23T10:02:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/01\/cac-kieu-du-lieu-trong-Java-vippro.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1500\" \/>\n\t<meta property=\"og:image:height\" content=\"790\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Tien Tran\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@ITviec\" \/>\n<meta name=\"twitter:site\" content=\"@ITviec\" \/>\n<meta name=\"twitter:label1\" content=\"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tien Tran\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 ph\u00fat\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java A-Z: \u0110\u1ecbnh ngh\u0129a v\u00e0 C\u00e1ch s\u1eed d\u1ee5ng - ITviec Blog","description":"Hi\u1ec3u r\u00f5 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java t\u1eeb ki\u1ec3u nguy\u00ean th\u1ee7y \u0111\u1ebfn ki\u1ec3u ph\u1ee9c t\u1ea1p, c\u00f9ng c\u00e1c v\u00ed d\u1ee5 gi\u00fap s\u1eed d\u1ee5ng ch\u00fang m\u1ed9t c\u00e1ch linh ho\u1ea1t v\u00e0 ch\u00ednh x\u00e1c.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/","og_locale":"vi_VN","og_type":"article","og_title":"C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java A-Z: \u0110\u1ecbnh ngh\u0129a v\u00e0 C\u00e1ch s\u1eed d\u1ee5ng","og_description":"Ki\u1ec3u d\u1eef li\u1ec7u \u0111\u00f3ng vai tr\u00f2 quan tr\u1ecdng trong vi\u1ec7c x\u00e2y d\u1ef1ng c\u00e1c \u1ee9ng d\u1ee5ng Java, gi\u00fap l\u1eadp tr\u00ecnh vi\u00ean x\u00e1c \u0111\u1ecbnh v\u00e0 qu\u1ea3n l\u00fd hi\u1ec7u qu\u1ea3 c\u00e1ch l\u01b0u tr\u1eef, x\u1eed l\u00fd d\u1eef li\u1ec7u","og_url":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/","og_site_name":"ITviec Blog","article_publisher":"https:\/\/www.facebook.com\/ITviec","article_published_time":"2025-01-23T10:02:05+00:00","og_image":[{"width":1500,"height":790,"url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/01\/cac-kieu-du-lieu-trong-Java-vippro.jpg","type":"image\/jpeg"}],"author":"Tien Tran","twitter_card":"summary_large_image","twitter_creator":"@ITviec","twitter_site":"@ITviec","twitter_misc":{"\u0110\u01b0\u1ee3c vi\u1ebft b\u1edfi":"Tien Tran","\u01af\u1edbc t\u00ednh th\u1eddi gian \u0111\u1ecdc":"14 ph\u00fat"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#article","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/"},"author":{"name":"Tien Tran","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/1595d671c49cfa2a48cd3c0a047a1298"},"headline":"C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java A-Z: \u0110\u1ecbnh ngh\u0129a v\u00e0 C\u00e1ch s\u1eed d\u1ee5ng","datePublished":"2025-01-23T10:02:05+00:00","mainEntityOfPage":{"@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/"},"wordCount":3713,"publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"image":{"@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/01\/cac-kieu-du-lieu-trong-Java-vippro.jpg","articleSection":["Chuy\u00ean m\u00f4n IT"],"inLanguage":"vi"},{"@type":"WebPage","@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/","url":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/","name":"C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java A-Z: \u0110\u1ecbnh ngh\u0129a v\u00e0 C\u00e1ch s\u1eed d\u1ee5ng - ITviec Blog","isPartOf":{"@id":"https:\/\/itviec.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#primaryimage"},"image":{"@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#primaryimage"},"thumbnailUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/01\/cac-kieu-du-lieu-trong-Java-vippro.jpg","datePublished":"2025-01-23T10:02:05+00:00","description":"Hi\u1ec3u r\u00f5 c\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java t\u1eeb ki\u1ec3u nguy\u00ean th\u1ee7y \u0111\u1ebfn ki\u1ec3u ph\u1ee9c t\u1ea1p, c\u00f9ng c\u00e1c v\u00ed d\u1ee5 gi\u00fap s\u1eed d\u1ee5ng ch\u00fang m\u1ed9t c\u00e1ch linh ho\u1ea1t v\u00e0 ch\u00ednh x\u00e1c.","breadcrumb":{"@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#breadcrumb"},"inLanguage":"vi","potentialAction":[{"@type":"ReadAction","target":["https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/"]}]},{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#primaryimage","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/01\/cac-kieu-du-lieu-trong-Java-vippro.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2025\/01\/cac-kieu-du-lieu-trong-Java-vippro.jpg","width":1500,"height":790,"caption":"ca\u0301c kie\u0302\u0309u du\u031b\u0303 lie\u0323\u0302u trong Java - itviec blog"},{"@type":"BreadcrumbList","@id":"https:\/\/itviec.com\/blog\/cac-kieu-du-lieu-trong-java\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Chuy\u00ean m\u00f4n IT","item":"https:\/\/itviec.com\/blog\/chuyen-mon-it\/"},{"@type":"ListItem","position":2,"name":"C\u00e1c ki\u1ec3u d\u1eef li\u1ec7u trong Java A-Z: \u0110\u1ecbnh ngh\u0129a v\u00e0 C\u00e1ch s\u1eed d\u1ee5ng"}]},{"@type":"WebSite","@id":"https:\/\/itviec.com\/blog\/#website","url":"https:\/\/itviec.com\/blog\/","name":"ITviec Blog","description":"IT Jobs &amp; People in Vietnam","publisher":{"@id":"https:\/\/itviec.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/itviec.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"vi"},{"@type":"Organization","@id":"https:\/\/itviec.com\/blog\/#organization","name":"ITviec","url":"https:\/\/itviec.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2018\/12\/itviec-black-square-facebook.png","width":1800,"height":1800,"caption":"ITviec"},"image":{"@id":"https:\/\/itviec.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ITviec","https:\/\/x.com\/ITviec","https:\/\/www.linkedin.com\/company\/itviec","https:\/\/www.youtube.com\/channel\/UCYthAQ3bcGr57M_ag5gHDvQ"]},{"@type":"Person","@id":"https:\/\/itviec.com\/blog\/#\/schema\/person\/1595d671c49cfa2a48cd3c0a047a1298","name":"Tien Tran","image":{"@type":"ImageObject","inLanguage":"vi","@id":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/05\/tien-tran-author-e1715658627643-100x100.jpg","url":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/05\/tien-tran-author-e1715658627643-100x100.jpg","contentUrl":"https:\/\/itviec.com\/blog\/wp-content\/uploads\/2024\/05\/tien-tran-author-e1715658627643-100x100.jpg","caption":"Tien Tran"},"url":"https:\/\/itviec.com\/blog\/author\/tien-tran\/"}]}},"_links":{"self":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/84251","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/users\/203"}],"replies":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/comments?post=84251"}],"version-history":[{"count":0,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/posts\/84251\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media\/84281"}],"wp:attachment":[{"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/media?parent=84251"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/categories?post=84251"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itviec.com\/blog\/wp-json\/wp\/v2\/tags?post=84251"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}