tag:blogger.com,1999:blog-741750605858169835.post2742963889474860609..comments2024-01-24T14:53:02.919+00:00Comments on Stephen Colebourne's blog: Changing Java: Adding simpler primitive creationStephen Colebournehttp://www.blogger.com/profile/01454237967846880639noreply@blogger.comBlogger5125tag:blogger.com,1999:blog-741750605858169835.post-27931755104336338952005-11-30T10:05:54.000+00:002005-11-30T10:05:54.000+00:00For the binary thing, why not just use 0x252524a4?...For the binary thing, why not just use 0x252524a4? Standard, compact, easy to read and understand, and doesn't require yet another extension to the language.Norman H. Azadiannoreply@blogger.comtag:blogger.com,1999:blog-741750605858169835.post-18589777837358782622005-11-27T12:06:38.000+00:002005-11-27T12:06:38.000+00:00The binary-thing could also be done like this:
int...The binary-thing could also be done like this:<br />int binary = Integer.parseInt("1001010", 2);<br /><br />Isn't such a big deal at all (at least it is far more readable), though I'd as well prefer doing this without a new String-object.<br /><br />0b1001010 would seem to be a valid choice when you remember 0xFFF or something like that.Patrick Gotthardtnoreply@blogger.comtag:blogger.com,1999:blog-741750605858169835.post-41378019146917974402005-11-27T00:31:57.000+00:002005-11-27T00:31:57.000+00:00I think there's a typo there:
someByteMethod((...I think there's a typo there:<br />someByteMethod((byte 2));<br /><br />I guess you mean:<br />someByteMethod((byte) 2);Daniel WECKhttp://del.icio.us/daniel.wecknoreply@blogger.comtag:blogger.com,1999:blog-741750605858169835.post-90333140912561131392005-11-26T22:51:28.000+00:002005-11-26T22:51:28.000+00:00Thanks JiaYun, I've rewritten the article to c...Thanks JiaYun, I've rewritten the article to clarify the problem.Stephen Colebournenoreply@blogger.comtag:blogger.com,1999:blog-741750605858169835.post-27082604251282271042005-11-26T21:04:15.000+00:002005-11-26T21:04:15.000+00:00It is legal to write "short val1 = 2;" a...It is legal to write "short val1 = 2;" and "byte val1 = 2;", you don't need to cast them.<br /><br />JLS 5.2 : http://java.sun.com/docs/books/jls/third_edition/html/conversions.html#5.2<br /><br />The compile-time narrowing of constants means that code such as:<br /><br />byte theAnswer = 42;<br /><br />is allowed. Without the narrowing, the fact that the integer literal 42 has type int would mean that a cast to byte would be required:<br /><br />byte theAnswer = (byte)42; // cast is permitted but not requiredJiaYunhttp://www.jiayun.org/noreply@blogger.com