Primitive data type

what primitive data type allows values 0998, or 02333… etc.
(int. doesn’t work for me when i use BlueJ)


Can you be more specific?

I’ll make an assumption and guess that you want a type int that tracks the value of a number and a single digit 0 in front of it.

But the more important question is: what to use it for?

I’ll make another assumption and guess you want it to display to the user as 0xxx (where x are arbitrary digits). If this is the case, then you can create a method that takes an int and returns a String of that int with a 0 concatenated in the front.

If it’s for something like identification or credit card validation, where you conceivably do want to keep track of the 0’s in their numeric essence, you could consider an array or even a linked list to store the digits. That way you have something like [0, 4, 5, 3].

1 Like