Java: Adagio For Strings

(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.

Continue reading

Advertisements

Java: Numbers and Numeric Promotion

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

Java: Garbage Collection

Garbage collection in Java is kind of, well, garbage. What is it? It’s the process by which the Java Virtual Machine cleans up no longer used pieces of memory (objects that are out of scope, for example), in order to keep memory free. It’s a bit of an odd beast, though. You can explicitly call it, but sometimes it will run, sometimes it won’t. Continue reading

Java: Variable Naming

Variables are pretty self explanatory, they are used to hold references to points in memory that store information (ok, maybe not that self explanatory). Things like strings, integers, doubles, objects, everything, in fact, can be stored as a variable. They are for the most part pretty simple, but, as always, there’s some odd and confusing edge cases to be aware of when using them.

Continue reading

Java: Class Structure

There may be one or two people who click onto this article expecting a discussion on socialism, sorry to disappoint, but it’s still about Java!

We touched briefly on class structure in the last post, but now I want to dive into a bit more detail on the different components of a java class. Most of it is pretty basic, but there may be one or two parts that surprise you.

Continue reading