There are lots of methods available for manipulating strings in Java, which is great because it takes some of the workload off developers and gives us more time to reinvent the wheel and drink coffee. They’re all pretty self-explanatory, and we’ll briefly look at a few of them here.
(I’m not really sure the joke in the title makes sense, but we’ll run with it for now)
Right, so, strings. Strings are a bit of a strange object in Java, and they’re treated differently to other objects. This is mostly for convenience (however much you may think that Java is out to get you), as you’ll see below.
You know everything about loops, right? For or While, they’re simple, and there’s nothing more to be said on that. With that in mind, have a look at the following code, and ask yourself what it does, and if it’s valid. Continue reading
Ok, so 3 posts a month isn’t exactly great, let’s see if I can’t up the ante a little bit for the next few weeks….*
There’s more Java to be learned! (and maybe something non-Java coming soon, because writing about the same topic can get a little boring….)
*in no way a guarantee.
Let’s see how much you were paying attention. What’s the output of the following code (How many times is “Message” printed out)?
You know what operators are, right? +, -, *, ! and so on. An operator is technically defined as a special symbol that can be applied to variables or literals. There are three types in Java: unary, binary, and ternary. That may sound confusing, but I’m betting you already know what all of them are, you just might not have heard them described like that before. Continue reading
Numbers, kind of a backbone of, well, most things when you think about it. This post will cover how Java treats typed numbers in code, which are called literals or sometimes also referred to as magic numbers (depending on how sarcastic the person reviewing your code is), and how numeric promotion works. What possible depth could there be to number literals in Java you ask? I’m glad you asked (but I bet you aren’t!). Continue reading