ec2-18-208-159-25.compute-1.amazonaws.com | ToothyWiki | RecentChanges | Login | Webcomic This is intended to end up a sort of repository for all the little hints I pick up whilst relearning this language.
Java the environment is utterly awful because you can't rely * upon anything you need actually being there. (And Java was an utter mess of inconsistencies in version one)
Java 1.4 supports the kitchen sink. Which makes it a joy to code. But nothing supports Java 1.4
When Java throws an error, it throws an exceptionally precise one - which is almost never the actual root cause. All programming environments seem to be like this, but I have to learn a new mapping.
[Eclipse] is actually rather a nice IDE (although PeterTaylor doesn't like the way the main method for writing compile scripts it provides is Ant).
Wouldn't know, not using any (not automagically created) compile scripts. But I understand that you can configure it to use whatever external tools you want. --Vitenka
I didn't want to spend a day reading the documentation to find out how. AFAIC, that's the sort of thing which should be sufficiently obvious when you look through the menu items, and it wasn't.
It really is nice to not have any link phase when compiling. Just hit Ctrl-S in the IDE and you're done.
Sadly this means that things like 'you called a method which doesn't exist' aren't normally picked up until /RunTime?. Score another one for the IDE here.
Eclipse has its own compiler, ECJ. It has one or two bugs not in Sun's one.
There may be a lot of people raving about using XML for config files and so on - but there's a real dearth of hints as to where to get helper classes and XML editors / schema designers that are, you know, usable.
Have you looked at Sax? I don't know how usable it is, but I believe it's widely used.
Nope, will do. Problem is that there seem to be sooo many that I don't know which to try hard with. --Vitenka
PeterTaylor has started writing an FAQ (no longer online) which he intended to point people towards when relevant.
Handy. The String concat thing - is this likely to be a problem? I'm using it for debug - a LOT - and I don't think Java has any conditional compilation options to let me ditch all that. Oh, hang on - belay that. Unless the code is being executed it doesn't take time (though I'd still rather conditionally compile than use 'if') - but when I am running with debug on, is it really as horribly inefficient as it sounds? I mean, if Java can't cope with creating cheap temporary objects, then why the heck does it force you to use objects and pretty much prevent their re-use? --Vitenka
The problem with String concat isn't the object creation - object creation is slow, but you're only creating O(n) objects. The problem is that you're doing O(n^2) character-copying operations. This is the reason for StringBuffer? - so that you're not forced either to do String concat or to write your own StringBuffer?.
Well, I'm just doing String + String + ... I've got no idea what that resolves to. (Which is yet another question - how do I overload the +, < etc. operators for my own classes) --Vitenka
Compiler turns it into StringBuffer? operations. It's string concat in a loop which is a bad idea.
Ok, that's a good thing. What about my other bit of question? --Vitenka
Operator overloading not permitted.
But.. but.. String does it! String is just an object... Why can't I do it? That's not FAIR! I'm gonna tell mommy on you, Java :) Ok, now that the tantrum is out of the way - seriously - why the heck not? I don't want to have to write: if ( version.isLessThan?( native_version ) ) over and over (or even copy and paste it) - I'd much rather have the more obvious if ( version < native_version ) --Vitenka
The exception: IllegalMonitorException? : Thread does not own objects monitor - actually means "In order to be allowed to wait() or similar, the method you are in must be synchronised."
Not quite. You must have synchronised on the object. Whether that's by having a synchronized method and waiting on this, or by using a synchronized block, is irrelevant.
Well, all I wanted to do was wait() for a little while. The error was totally nonsensical for that. (such thoughts as, ok, where is the GetMonitor?() method then?)
To set the default locale, use the system properties user.language and user.country (and user.variant if you need it). E.g. for default locale en_GB use -Duser.language=en -Duser.country=GB. For default locale es_ES_Traditional_WIN, use -Duser.language=es -Duser.country=ES -Duser.variant=Traditional_WIN. For some reason this doesn't appear to be documented anywhere. Not guaranteed to work with non-Sun or with J2ME VMs.