File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes java integer data types Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "java integer data types" Watch "java integer data types" New topic

java integer data types

RajivAwadhesh kumar

Joined: May 20, 2011
Posts: 24
Why java does not have unsigned integer types?
Paul Clapham

Joined: Oct 14, 2005
Posts: 19973

Because the designers of the language decided not to include them.
RajivAwadhesh kumar

Joined: May 20, 2011
Posts: 24
what is the idea behind not including unsigned integer types in java?
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 15084

Right from the horse's mouth, Java inventor James Gosling:
James Gosling wrote:
For me as a language designer, which I don't really count myself as these days, what "simple" really ended up meaning was could I expect J. Random Developer to hold the spec in his head. That definition says that, for instance, Java isn't -- and in fact a lot of these languages end up with a lot of corner cases, things that nobody really understands. Quiz any C developer about unsigned, and pretty soon you discover that almost no C developers actually understand what goes on with unsigned, what unsigned arithmetic is. Things like that made C complex. The language part of Java is, I think, pretty simple. The libraries you have to look up.

So, it is because James thought unsigned integer arithmetic was too confusing for the average developer.

Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11955

I would also turn the question around...

Why do you think they SHOULD have included unsigned ints? What purpose would they gain you that you can't get by using un-signed.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
I agree. Here's the link:
subject: java integer data types
It's not a secret anymore!