This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes  cannot convert from long to byte Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark " cannot convert from long to byte" Watch " cannot convert from long to byte" New topic
Author

cannot convert from long to byte

Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

for some reason I get this error in this code, how can I fix it?



Jesus lives
Keith Lynn
Ranch Hand

Joined: Feb 07, 2005
Posts: 2367
Are you familiar with casting?
Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

yes, I tried this and it worked, thanks
Nikos Stavros
Ranch Hand

Joined: Feb 24, 2006
Posts: 243

however I get strange results


It prints out "-77 -77 -77 -77" I can figure out why I get the same numbers
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14192
    
  20

Hint: The >> operator has preference above the & operator.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
 
GeeCON Prague 2014
 
subject: cannot convert from long to byte