In this article, we’re going to go over some final glossary terms about Java’s language system in order to give you a fuller understanding of what Java is and how it works. These items are language features of how Java constructs meaning and structures its code. In a lot of ways, expressions like these and the operators and operands covered in the previous article are the fundamental building blocks that Java allows designers to use in order to create the expressions that make up Java. In this article, we’ll go through each of them and say a little about what they are and how they can be used in Java.
Although comments aren’t really an integral part of using Java – that is, they don’t contribute to the functionality of any source code you write in Java – they are important for the purposes of documentation. Documentation is really helpful when you need to return to a project you worked on a while ago and you’ve forgotten why you main certain decisions or wrote your code the way that you did.
The important thing to remember is to document while you’re working, otherwise it’s something that can fall by the wayside. In terms of comments on Java code, there are generally, three ways that Java allows you to do that.
- Single line comments span a single line. They’re useful for pointing out something very specific or giving a short but meaningful description of something.
- Multiline comments, predictably, span multiple lines. They start with /* through */ and they’re ignored by the compiler. They’re good for providing a detailed description of what’s going on in your code, or showing a list of your own shorthand in that section.
- Finally, you can also use Javadoc comments, which are a particular type of multiline comments. They start with /** and end with */. The difference is that they can be expanded and contracted, like a spoiler tag on an online forum.
See how to comment in action here:
Java uses references to specific classes of items in its code. Identifiers are tags used to connect a particular thing with its code. Identifiers use letters, numbers, and a few special characters like currency symbols. It’s important to note that valid identifiers must begin with a letter or a currency symbol. Invalid identifiers begin with numbers, or they contain characters that are invalid, such as the @ sign or spaces in the text. It’s also important to note that Java is a case-sensitive language, which means that an identifier called ‘age’ is different from another identifier called ‘Age.’ There are also keywords that have been reserved by Java to refer to particular functions. Make sure to check these out so you don’t get a compiler error when you’re trying to put everything together.
Learn more here:
Types are fairly important to Java. This makes sense because Java is described as a heavily-typed language. Types are a feature for classifying values, which means that a type is a set of those values which represents what they look like in the memory and how the set of operations controlling those values functions. There are a whole lot of types available in Java (as again, it is heavily typed). These types come in the form of primitive types, whose values are not objects, reference types, which is a type that is sort of a pointer to objects and classes, and array types, which are like reference types except that they point to an array, which is a sequence or region of memory with things contained in it.
The literals language feature is one that allows users to embed values into source code. The literal, then, is that value’s character representation. There are a few primitive literal types that are generally used in Java code. The Boolean primitive type uses true and false as its binary literal types. The Character primitive type has, unsurprisingly, character literals. These are single values in quotes or expressed as capital letters. Integer types are also associated with literals, as are floating point types. Both of these literals stand in for numeric values, the difference being whether that value involves decimal points or not.
Learn more here:
The final entry into our glossary is variables. These are used to store values in Java’s code. Unlike literals and reference types, which simply point to the location of a value, variables literally create a repository, a named memory location, where the data is stored. Variables can also be involved with reference types, which results in a reference variable, which points to location of a variable storage cache. Variables have to be declared before they’re used, but otherwise the process for setting them up and using them is the same as it is to use any of the other language expressions in this article.
Learn more here:
Hopefully, you learned all that you’ll need to in order to either deepen your existing understanding of Java, or give you a basis of knowledge that you can use to start using Java in the near future.