08 December 2005 - java_dev (original) (raw)

12:14 pm - ramou - Java 1.5, implications for OO I've been wondering what the exact details were for some time, and the new features have come up in a recent comment thread. I've been doing java for a while, and like more than a few people in my shoes, I've been meaning to read up on the new stuff in 1.5, but haven't quite got around to it yet. So I looked a little bit:http://www.clanproductions.com/java5.html (the first link I found, I haven't looked further). Do people have better links? Is this link comprehensive?These are the new additions according to that link:* Generics* for-each loop* Autoboxing / unboxing* Type safe enumerations* Static imports* Variable argument lists (varargs)How do you feel about them? I like generics, for-each and static imports implicitly. They all solve things that have annoyed me for ages. Typesafe enumerations are something I never use, so I don't care, but maybe I'll use them now that it's so easy, but without having my hands dirty, I can't state a preference either way. Autoboxing and unboxing seemed cool, but someone has pointed out some possible areas of confusion WRT the various operators, i.e. == will not unbox, but will compare Integers (the objects, not the values), whereas <= will unbox. There's also the issue of caching, although I can't say I really understand that too clearly. Still, it's not like this makes it bad, it just seems that it means one has to be careful using this new toy.so, can we:int i = 1;int j = 1;i.equals(j); and have it autobox for us? I know, I could test this myself, but whether it works or not, the idea is still interesting.Lastly, there's the varargs. I always felt dirty using that in C++ (or C... whatever). I was horrified to see it in J1.5. I'm not sure why the parameter gets changed to an array and not to a Collection, which would have seemed neater to me. I can bet that a lot of older programmers wanted this feature. I'm sure I've heard my old man gripe about it, too. But, besides giving those older programmers something familiar, how much does it really add? When is it really appropriate to use this? How would one go about teaching students not to use this because they think it's neat because it might bite them in the arse down the road when the requirements change? How do we show them when it is appropriate (do I hear a new pattern)?So, the post is on this topic, feel free to post your opinions either way, complain about performance or OOness (are they mutually exclusive... sometimes). I only learned half this stuff in the last week or so, so feel free to comment beginner questions or advanced, as you see fit. If I've missed any differences with J1.5 (did they do additional under the hood performance tweaks?), feel free to chime in.
02:21 pm - deana_in_texas I'm trying to create a game. It has gotten to the point where the game board does not fit on the screen, so I would like to add some scroll bars.The only way I have found to do this is to use a JScrollPane, but it says it only works with "lightweight" components. While I'm not 100% sure what that means, I'm pretty sure Canvas isn't one of them. I am currently drawing the gameboard on a Canvas, so I think that could cause a problem when I want to add scroll bars, yes?Anyone have experience with this kind of thing? Would using a BorderLayout on my JFrame that is the game work, and then just add JScrollBars to the borders and the Canvas in the middle? I've never tried to use scroll bars before, so I'm at a loss.Thanks for any help you can give.

| | 03:03 pm - ex_juan_gan - a piece of advice to students etc Dear friends!We all share your worries about your term papers due very soon, etc.There is a very, extremely good site: javaranch.com, where your simple, medium and tricky questions will be met with enthusiasm, by enthusiasts, and will be promptly answered. You, most probably, will be able to find there answers to your questions, too. That's what I did when I was just learning Java.As an alternative, you could set up your own community - but I am not sure whether you'll find people willing to tutor there. Javaranch is much better.Best regards,Vlad Patryshev | | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |