why does default value for char data type in java has 4 hex when it is a 16 bit datatype












-1















I am new to java, and this question may be silly to many.



When going through the basics, i learnt this:



char: The char data type is a single 16-bit Unicode character. It has a minimum value of 'u0000' (or 0) and a maximum value of 'uffff' (or 65,535 inclusive).



My question is why does the default, minimum and maximum have 4 hex when it can be only one?










share|improve this question


















  • 2





    Why do you think it can only be one?

    – Max Vollmer
    Nov 24 '18 at 0:27











  • @max I think OP means it can only have 1 value (at a time) but it seems to have 1 “u” and 4 “f” values.

    – Bohemian
    Nov 24 '18 at 0:29











  • Exactly what do you mean by “one value” and “4 hex”? Do you now about hex literals?

    – Bohemian
    Nov 24 '18 at 0:31











  • Thanks @bohemian , I completely missed the point , that one F is binary 1111 ( and exactly fits 4 bits). Super silly me :) :)

    – user8506488
    Nov 24 '18 at 18:12
















-1















I am new to java, and this question may be silly to many.



When going through the basics, i learnt this:



char: The char data type is a single 16-bit Unicode character. It has a minimum value of 'u0000' (or 0) and a maximum value of 'uffff' (or 65,535 inclusive).



My question is why does the default, minimum and maximum have 4 hex when it can be only one?










share|improve this question


















  • 2





    Why do you think it can only be one?

    – Max Vollmer
    Nov 24 '18 at 0:27











  • @max I think OP means it can only have 1 value (at a time) but it seems to have 1 “u” and 4 “f” values.

    – Bohemian
    Nov 24 '18 at 0:29











  • Exactly what do you mean by “one value” and “4 hex”? Do you now about hex literals?

    – Bohemian
    Nov 24 '18 at 0:31











  • Thanks @bohemian , I completely missed the point , that one F is binary 1111 ( and exactly fits 4 bits). Super silly me :) :)

    – user8506488
    Nov 24 '18 at 18:12














-1












-1








-1








I am new to java, and this question may be silly to many.



When going through the basics, i learnt this:



char: The char data type is a single 16-bit Unicode character. It has a minimum value of 'u0000' (or 0) and a maximum value of 'uffff' (or 65,535 inclusive).



My question is why does the default, minimum and maximum have 4 hex when it can be only one?










share|improve this question














I am new to java, and this question may be silly to many.



When going through the basics, i learnt this:



char: The char data type is a single 16-bit Unicode character. It has a minimum value of 'u0000' (or 0) and a maximum value of 'uffff' (or 65,535 inclusive).



My question is why does the default, minimum and maximum have 4 hex when it can be only one?







java






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 24 '18 at 0:24









user8506488user8506488

301




301








  • 2





    Why do you think it can only be one?

    – Max Vollmer
    Nov 24 '18 at 0:27











  • @max I think OP means it can only have 1 value (at a time) but it seems to have 1 “u” and 4 “f” values.

    – Bohemian
    Nov 24 '18 at 0:29











  • Exactly what do you mean by “one value” and “4 hex”? Do you now about hex literals?

    – Bohemian
    Nov 24 '18 at 0:31











  • Thanks @bohemian , I completely missed the point , that one F is binary 1111 ( and exactly fits 4 bits). Super silly me :) :)

    – user8506488
    Nov 24 '18 at 18:12














  • 2





    Why do you think it can only be one?

    – Max Vollmer
    Nov 24 '18 at 0:27











  • @max I think OP means it can only have 1 value (at a time) but it seems to have 1 “u” and 4 “f” values.

    – Bohemian
    Nov 24 '18 at 0:29











  • Exactly what do you mean by “one value” and “4 hex”? Do you now about hex literals?

    – Bohemian
    Nov 24 '18 at 0:31











  • Thanks @bohemian , I completely missed the point , that one F is binary 1111 ( and exactly fits 4 bits). Super silly me :) :)

    – user8506488
    Nov 24 '18 at 18:12








2




2





Why do you think it can only be one?

– Max Vollmer
Nov 24 '18 at 0:27





Why do you think it can only be one?

– Max Vollmer
Nov 24 '18 at 0:27













@max I think OP means it can only have 1 value (at a time) but it seems to have 1 “u” and 4 “f” values.

– Bohemian
Nov 24 '18 at 0:29





@max I think OP means it can only have 1 value (at a time) but it seems to have 1 “u” and 4 “f” values.

– Bohemian
Nov 24 '18 at 0:29













Exactly what do you mean by “one value” and “4 hex”? Do you now about hex literals?

– Bohemian
Nov 24 '18 at 0:31





Exactly what do you mean by “one value” and “4 hex”? Do you now about hex literals?

– Bohemian
Nov 24 '18 at 0:31













Thanks @bohemian , I completely missed the point , that one F is binary 1111 ( and exactly fits 4 bits). Super silly me :) :)

– user8506488
Nov 24 '18 at 18:12





Thanks @bohemian , I completely missed the point , that one F is binary 1111 ( and exactly fits 4 bits). Super silly me :) :)

– user8506488
Nov 24 '18 at 18:12












2 Answers
2






active

oldest

votes


















3














I think you need to read up on numeral systems.



Binary: Represents numbers using 2 digits, 0 and 1.



Decimal: Represents numbers using 10 digits, 0 - 9.



Hexadecimal: Represents numbers using 16 digits, 0 - F.



A char in Java is a type that can hold numbers with 16 bits, i.e. in the range 0 - 1111111111111111 in binary, 0 - 65535 in decimal or 0 - FFFF in hexadecimal.






share|improve this answer
























  • Thanks @max , I completely missed the point , that that one F is binary 1111 ( and exactly fits 4 bits)

    – user8506488
    Nov 24 '18 at 18:11



















2














Hex F is decimal 15 or binary 1111. It fits exactly in 4 bits. a 16-bit value can hold 4 times 4 bits, hence from 0x0000 to 0xFFFF (which is 2^16 = 65,536).



The u in your example is for Unicode, pretty much saying that you can store unicode characters that take up to 16 bits, from u0000 to uFFFF.






share|improve this answer
























  • Thanks @robert , now I get it perfectly, I had completely overlooked the fact that one F is binary 1111 (and fits exactly 4 bits) . The question was super silly to have been asked in a forum :) :). Thanks anyway

    – user8506488
    Nov 24 '18 at 18:07













Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454173%2fwhy-does-default-value-for-char-data-type-in-java-has-4-hex-when-it-is-a-16-bit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














I think you need to read up on numeral systems.



Binary: Represents numbers using 2 digits, 0 and 1.



Decimal: Represents numbers using 10 digits, 0 - 9.



Hexadecimal: Represents numbers using 16 digits, 0 - F.



A char in Java is a type that can hold numbers with 16 bits, i.e. in the range 0 - 1111111111111111 in binary, 0 - 65535 in decimal or 0 - FFFF in hexadecimal.






share|improve this answer
























  • Thanks @max , I completely missed the point , that that one F is binary 1111 ( and exactly fits 4 bits)

    – user8506488
    Nov 24 '18 at 18:11
















3














I think you need to read up on numeral systems.



Binary: Represents numbers using 2 digits, 0 and 1.



Decimal: Represents numbers using 10 digits, 0 - 9.



Hexadecimal: Represents numbers using 16 digits, 0 - F.



A char in Java is a type that can hold numbers with 16 bits, i.e. in the range 0 - 1111111111111111 in binary, 0 - 65535 in decimal or 0 - FFFF in hexadecimal.






share|improve this answer
























  • Thanks @max , I completely missed the point , that that one F is binary 1111 ( and exactly fits 4 bits)

    – user8506488
    Nov 24 '18 at 18:11














3












3








3







I think you need to read up on numeral systems.



Binary: Represents numbers using 2 digits, 0 and 1.



Decimal: Represents numbers using 10 digits, 0 - 9.



Hexadecimal: Represents numbers using 16 digits, 0 - F.



A char in Java is a type that can hold numbers with 16 bits, i.e. in the range 0 - 1111111111111111 in binary, 0 - 65535 in decimal or 0 - FFFF in hexadecimal.






share|improve this answer













I think you need to read up on numeral systems.



Binary: Represents numbers using 2 digits, 0 and 1.



Decimal: Represents numbers using 10 digits, 0 - 9.



Hexadecimal: Represents numbers using 16 digits, 0 - F.



A char in Java is a type that can hold numbers with 16 bits, i.e. in the range 0 - 1111111111111111 in binary, 0 - 65535 in decimal or 0 - FFFF in hexadecimal.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 0:31









Max VollmerMax Vollmer

5,75651837




5,75651837













  • Thanks @max , I completely missed the point , that that one F is binary 1111 ( and exactly fits 4 bits)

    – user8506488
    Nov 24 '18 at 18:11



















  • Thanks @max , I completely missed the point , that that one F is binary 1111 ( and exactly fits 4 bits)

    – user8506488
    Nov 24 '18 at 18:11

















Thanks @max , I completely missed the point , that that one F is binary 1111 ( and exactly fits 4 bits)

– user8506488
Nov 24 '18 at 18:11





Thanks @max , I completely missed the point , that that one F is binary 1111 ( and exactly fits 4 bits)

– user8506488
Nov 24 '18 at 18:11













2














Hex F is decimal 15 or binary 1111. It fits exactly in 4 bits. a 16-bit value can hold 4 times 4 bits, hence from 0x0000 to 0xFFFF (which is 2^16 = 65,536).



The u in your example is for Unicode, pretty much saying that you can store unicode characters that take up to 16 bits, from u0000 to uFFFF.






share|improve this answer
























  • Thanks @robert , now I get it perfectly, I had completely overlooked the fact that one F is binary 1111 (and fits exactly 4 bits) . The question was super silly to have been asked in a forum :) :). Thanks anyway

    – user8506488
    Nov 24 '18 at 18:07


















2














Hex F is decimal 15 or binary 1111. It fits exactly in 4 bits. a 16-bit value can hold 4 times 4 bits, hence from 0x0000 to 0xFFFF (which is 2^16 = 65,536).



The u in your example is for Unicode, pretty much saying that you can store unicode characters that take up to 16 bits, from u0000 to uFFFF.






share|improve this answer
























  • Thanks @robert , now I get it perfectly, I had completely overlooked the fact that one F is binary 1111 (and fits exactly 4 bits) . The question was super silly to have been asked in a forum :) :). Thanks anyway

    – user8506488
    Nov 24 '18 at 18:07
















2












2








2







Hex F is decimal 15 or binary 1111. It fits exactly in 4 bits. a 16-bit value can hold 4 times 4 bits, hence from 0x0000 to 0xFFFF (which is 2^16 = 65,536).



The u in your example is for Unicode, pretty much saying that you can store unicode characters that take up to 16 bits, from u0000 to uFFFF.






share|improve this answer













Hex F is decimal 15 or binary 1111. It fits exactly in 4 bits. a 16-bit value can hold 4 times 4 bits, hence from 0x0000 to 0xFFFF (which is 2^16 = 65,536).



The u in your example is for Unicode, pretty much saying that you can store unicode characters that take up to 16 bits, from u0000 to uFFFF.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 24 '18 at 0:30









RobertRobert

2,15962536




2,15962536













  • Thanks @robert , now I get it perfectly, I had completely overlooked the fact that one F is binary 1111 (and fits exactly 4 bits) . The question was super silly to have been asked in a forum :) :). Thanks anyway

    – user8506488
    Nov 24 '18 at 18:07





















  • Thanks @robert , now I get it perfectly, I had completely overlooked the fact that one F is binary 1111 (and fits exactly 4 bits) . The question was super silly to have been asked in a forum :) :). Thanks anyway

    – user8506488
    Nov 24 '18 at 18:07



















Thanks @robert , now I get it perfectly, I had completely overlooked the fact that one F is binary 1111 (and fits exactly 4 bits) . The question was super silly to have been asked in a forum :) :). Thanks anyway

– user8506488
Nov 24 '18 at 18:07







Thanks @robert , now I get it perfectly, I had completely overlooked the fact that one F is binary 1111 (and fits exactly 4 bits) . The question was super silly to have been asked in a forum :) :). Thanks anyway

– user8506488
Nov 24 '18 at 18:07




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53454173%2fwhy-does-default-value-for-char-data-type-in-java-has-4-hex-when-it-is-a-16-bit%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

404 Error Contact Form 7 ajax form submitting

How to know if a Active Directory user can login interactively

Refactoring coordinates for Minecraft Pi buildings written in Python