Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are there any equivalents to size_t in C++ in Java?

Tags:

java

c++

size-t

So I am VERY new to Java., but I actually really like it so far. I am comfortable in C++ and was trying to convert some of my code to learn more. I am stuck in translating my code at size_t. I know there are no unsigned integer types in Java, but could I use long instead? Would I just have to watch out for the case of negatives?

Thank for the insight!

like image 308
whla Avatar asked Sep 12 '25 05:09

whla


1 Answers

Java doesn't have unsigned types. But long in Java is 64-bit so it is definitely enough to be a size_t.

And, yes, for a bug free system, you can always watch out the unexpected case of negatives.

like image 199
nicky_zs Avatar answered Sep 13 '25 19:09

nicky_zs