Programming in Java: Variables

in #technology6 years ago

Just as you may have learned in Algebra or any math course, variables are place holders for numbers that we are trying to find. Common variables in Algebra are x and y. Likewise variables are a basic concept in any programming language. There many types of variables such as int, double, float, string, char, etc. These all are place holders meaning they hold a value that they are assigned. So if it is an int variable it hold a number like 4,3,787,89 etc. And a double holds a value like 5.6,5.7,6.8 etc. And a string is for example like the previous post "Hello World." So in programming all of these are used to hold values and depending on the type they vary. Here is an example using some of these variables.

As you can see in this picture I called variables and then assigned values to them.

Then after assigning them values I then printed them and got a result.

I added the ints together and the doubles together and the Strings together.

The result is what you see in the terminal it is a simple program but my point is

to show you how to assign and use variables because it is a fundamental concept in Java

and in programming in general.