Saturday 27 February 2016

Java Tutorial 5 - Comments

Last Time
Last time we looked at storing the values of calculations in variables and different types of variables.

This Tutorial
We're going to take a break from variables and look at comments

What is a comment?
A comment is some text within the program code which you can see in the code but not in the actual completed program. Only the programmer can see it, not the user.

Why is it useful?
They are used to describe what a part of the code does to make it easier to maintain that code later on

Using Comments
In Java, you can make a comment using 2 forward slashes like so

//This is a comment


That line will be ignored by the computer. Not that it does not need a semi colon

To make a multiline comment you can use a slash followed to an asterisk like so

/*
I
Am
A
Comment
Over
Some
Lines
*/

And end the comment with an asterisk and a slash. That's iot for today, next time we'll look at arrays

No comments:

Post a Comment