Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Compare byte to null?

807599Dec 13 2006 — edited Dec 13 2006
I need to compare a byte to a null value for a program I am writing, in order to catch these values to stop them being printed in an output file as "<nul>".

At first, I tried
      for (int i=1; i<=127; i++)
	if (AwaitData.received[i] == null)
but this gives the error:
StoreData.java:14: incomparable types: byte and <nulltype>

I then tried the idea of making a Byte and setting its value to null:
 Byte NULL = null; 
But this doesn't work either, giving a null pointer exception when I run the for loop:
Exception in thread "main" java.lang.NullPointerException
at StoreData.doIt(StoreData.java:14)

Is there any way of actually doing this?
Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2007
Added on Dec 13 2006
4 comments
3,979 views