You Are Here:

Community: Developer Discussion Boards

#1 Old Is byte converted to int in operations (+,-,*,/) ? - 2003-03-24, 10:18

Join Date: Mar 2003
Posts: 162
Location: Malaysia-Johor-Pontian Kecil
akokchai
Offline
Regular Contributor
Hi,
I read some articals, some developers suggest to use byte/short in some declaration instead of int. Becos it can save memory (runtime) and spaces (jar). But according to Java spec, byte/short would be converted to int when they are in operations. It makes me confused, if bye/short will be converted to ints. It's useless that using byte/short to declare variables, even I can confirm some variables' range are 0 ~ 255. For examples, I SHOULD use a byte to declare a for-loop (the maximum value is 10, byte is good enough to be used to declare b) :
for (byte b = 0 ; b < 10 ; b++) {}
instead of
for (int b = 0 ; b < 10 ; b++) {}
But my problem is that b will be converted to int here ? Becos of 'b++' ?
My purpose is saving the memory/jar size.
Thanks.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Forum Jump

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia