Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Unsigned integers in Java

 
Zaheer Ahmed
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All!

How can I declare the usigned primitive integers in Java???

I tried the following code:
<code>
public class TestUnsigned {
public static void main(String[] args) {
unsigned int a = 10;
System.out.println(a);
}
}
</code>

But the above code does not compile. It gives "Not a statement" error.

I remember doing something like this... I am not sure whether it was Java or C++. I know that Java is not C++ (Bert) and actually repeated that a couple of times but I am confused here...
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24212
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Java doesn't have unsigned ints. If a plain int can't hold a large enough value, and you want to keep the code simple, you can use a long.
 
Zaheer Ahmed
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That I was guessing... Thanks Ernest for clarifying it up...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic