Now that you have created your first variable, it's time to show you how to "print" it out and run the program. "Printing" out variables and running the program like this is called "debugging". The difference between running a program and debugging is that debugging is printing out values that variables are, or printing out a sentence/letters. Running a program is executing the tasks that you give it. It's like how a square is a rectangle, but a rectangle isn't a square. You'll see how in a second.
This tutorial's goal is to teach you the commands in a program that are either exactly the same or similar to other programs. These commands are identical in syntax or almost identical. Debugging, however, is different in every language. The concept is the same, but the syntax is almost completely different. For example, a command in Java to debug is "System.out.println();" and a command in C++ to debug is "Printf();". Here is a list of the differences in common languages used:
[chart of debugging for different languages]
Since I'm using Java for this tutorial, I need to use "System.out.println();" to debug. You can do two things with debugging, like I briefly mentioned before. One of the things to do with debugging is to print out a sentence or word or phrase. To do this, in the parentheses (also known as parameters, and will be called as such from now on), surround the sentence/word/phrase with quotation marks like so:
[picture of debugging with a word]
If you run the program, it will print out this:
[picture of the already run program printing out the word]
The second thing you can do with debugging is printing out a variable. We are going to have to declare a variable first, however, to print it out.
[picture of declared variable with a blank debug command]
To print out a variable, instead of putting quotation marks, this works with just putting the name of the variable inside the parameters.
[picture of debug command with variable inside]
Once you run the program, it should print out this:
[picture of the already run program printing out the variable]
Congrats! You've successfully declared and printed out your first variables!
This tutorial's goal is to teach you the commands in a program that are either exactly the same or similar to other programs. These commands are identical in syntax or almost identical. Debugging, however, is different in every language. The concept is the same, but the syntax is almost completely different. For example, a command in Java to debug is "System.out.println();" and a command in C++ to debug is "Printf();". Here is a list of the differences in common languages used:
[chart of debugging for different languages]
Since I'm using Java for this tutorial, I need to use "System.out.println();" to debug. You can do two things with debugging, like I briefly mentioned before. One of the things to do with debugging is to print out a sentence or word or phrase. To do this, in the parentheses (also known as parameters, and will be called as such from now on), surround the sentence/word/phrase with quotation marks like so:
[picture of debugging with a word]
If you run the program, it will print out this:
[picture of the already run program printing out the word]
The second thing you can do with debugging is printing out a variable. We are going to have to declare a variable first, however, to print it out.
[picture of declared variable with a blank debug command]
To print out a variable, instead of putting quotation marks, this works with just putting the name of the variable inside the parameters.
[picture of debug command with variable inside]
Once you run the program, it should print out this:
[picture of the already run program printing out the variable]
Congrats! You've successfully declared and printed out your first variables!