First off, I’d like to mention that I’m writing these preliminary posts in a way that I’ll presume you have very little knowledge of programming.
Thus, let’s begin with our first topic: The 5 basic theories of any programming language. You might say, “Are we speaking about some other programming language? Well, I have discovered that it’s important to remember that a lot of programming languages are very similar, and understanding what is common between all programming languages will help you transition into any other programming language should you need to! For example, using the Java programming knowledge I’d acquired, it took me less than a month to learn how to program in a language called Objective C (that is used for iPhone programs ). That is powerful stuff! You can also learn more from will-power-forum.com
Before we start learning: if you’re someone who also enjoys learning by viewing movies, then I’ve got the perfect deal for you. You can click here to find out more about the Java classes.
2. Control Structures
3. Data Structures
I recognize that these words probably look foreign to you, but do not worry, I will do my very best at taking the mystery out of them. Now, there’s a lot to say about every one of these 5 concepts, so for today’s article, I’ll only be talked about thing #1, variables!
What is a variable?
I like to start off by defining what we’re going to learn, so, Wiki defines a variable as follows:
In computer programming, a factor is a storage location and an associated symbolic name that contains some unknown or known quantity or data, a worth.
Okay, well, that is kind of mysterious. For me, a variable is simply a means to store some sort of information for later usage, and we could retrieve this information by simply referring to a”word” that will describe this information.
For instance, let’s say you visit my site www.howtoprogramwithjava.com and the very first thing I would like to do, is asking you what your name is (so that I can greet you in a nice manner the next time you go to my site ). I would put a little text box on the screen that asks you what your title is… that text would represent a variable! Let us say I called that text box’yourName’, that would be the emblematic name (or”word”) to your factor (as explained from our wiki definition above).
So today, when you type your name into the text box, that information would be stored in a variable called’username’. I would then have the ability to come back and say”What worth does the factor ‘yourName’ include?”, and the program will tell me whatever it was your own typed into that text box.
This idea is extremely powerful in programming and is utilized constantly. It’s what makes Facebook and Twitter operate, it’s what makes paying your bills through your online bank work, it’s what allows you to put a bid on eBay.
But if we want to acquire more specific, when it comes to the Java programming language, variables have distinct kinds. Brace yourself, as I’m going to try to confuse you by describing a significant idea in three paragraphs. If I had been storing your name in a variable, that kind would be a String. Or, let’s say I wanted to store your age, that kind will be saved as an Integer. Or let’s say I needed to save how much money you make in a calendar year, which type will be saved as a Double.
What the heck are String, Integer and Double?
Excellent question! In Java, the programming language wishes to understand exactly what type of information you’re likely to be saving in a factor. I could teach you about what the difference is between a strongly typed language and a weakly typed language, but this will likely bore you right now, so let us just focus on what a kind is in Java and it’s significant.
Typing in Java enables the programming language to understand with complete certainty that the information being stored in a variable will be’a certain way’. So like I said, if you are keeping your age, you would use the Integer type… well that’s because, in Java, an Integer means you’ve got a number that will not have any decimal places in it. It will be a whole number, like 5, 5, or 20, or 60, or even -60, or even 4000, or even -16000. All those numbers are regarded as an Integer in Java.
So what would happen if you tried to store something which was not an Integer, into an Integer variable, say for instance the value”$35.38″? Well, quite simply, you would get an error in the program and you may need to fix it! “$35.38″ has a dollar sign ($) in it, as well as a decimal place using two digits of precision. In Java, once you define that a variable is of type Integer, you are simply not allowed to store anything except a whole number.
Specifying what type of data which you are dealing with allows the programming language to utilize that information in interesting ways. Again, what I say”specifying what kind of data”, I’m simply referring to this kind of information.
Let us dive into the power of assigning a kind to your data.
What can you do with data types?
Let’s start with a very simple illustration.
Your want is to add two numbers together, let us state the number 22 and the number 3. Java will act differently based on the kind of variable that is storing this data.
If you have defined your variables to be of kind Integer, then including 22 and 3 together will end in the Integer 25. Makes perfect sense? Of course, this is easy Math.
But what happens if your variables aren’t Integers, but are Strings?
A String from Java is a different kind of data type and it behaves differently since it is not the same type of data.
When we refer to some String in Java (and in many other programming languages) were handling the data like it’s only a plain old sentence in the English language. A String just signifies words (or more specifically letters) all put in a particular order. That is all the English language (or any language) isa succession of characters/letters put in a particular order to give meaning to what you are writing down.
I ask you, what exactly does it mean to add two paragraphs together? What exactly does it mean to add 2 Strings together?
I will show you.
In the event that you were to get 2 factors, each defined as Strings and they saved the information”22″ and”3″ (respectively), what would happen when we added them together?
We would get the String:”223″
This may be confusing initially, however, it makes more sense once we use less”misleading” data.
Let us assume that in both String variables, we are not storing numbers, we are storing words.
Today what happens in your head if I tell you to bring those 2 words together?
Hopefully your natural instinct is to say that the resulting String will be”Hello World”!
That’s all that is happening with all the Strings”22″ and”3″… Java behaves differently due to the type of these variables.
On Java, the String”22″ is exactly the same kind of information as the String”twenty-two”, they are both characters organized in a specific way.
I don’t want to enter a lot of detail about types, as this is much better suited to programming basic notion #3 — Data Structures. So that is all I will touch on for today, but no worries, it’ll all make sense in time!
Want Free Access to my Best Java Courses?
Alright, so if you’re read this far down the guide, then you are clearly interested in figuring out how to code. You can currently get access to my 2 best classes on Java for free for 30 times (then it’s just $10/month later, or even $97/year).
When you register you will receive login information to start learning Java. In case you decide you do not like the courses, you can cancel at any moment. If you decide you love the courses then you do not need to do anything and you can remain subscribed for as long as you like for only $10/month or $97/year.
So, to sum up, we talked about what a variable is and how you can store information at a variable then recover that information at a later point in time. The factor can have a title , and this particular name you contribute to the variable is usually named after the sort of material you are going to be saving in the variable, so when I’m keeping your name in the factor, you’d name the factor’yourName’. You wouldn’t need to give this name, you can name the factor”holyCrapImProgramming”, but that would not make a great deal of sense considering you’re attempting to store a person’s name. Makes sense ? Finally, variables have types, and these kinds are utilized to help us arrange what can and cannot be stored in the variable. Hint: having a typewill help open up what kind of things we could do with the information inside the factor . Example: if you’ve got two Integers (let’s say 50 and 32), then you’d be able to subtract one variable from the other (i.e 50 — 32 = 18), fairly straight forward perfect? So, types are also a potent thing, and they help us to make sense of what we CAN do together with our factors and what we CANNOT do!
I hope this information has been useful to you, and I hope you understand what the benefits of learning a programming language are! The allure to learning a programming language is very high in today’s corporate world, since most companies are hiring programmers with the skills to make web applications. The programming profession is one which offers exceptional cover and job stability, and in the end, is not that what we’re all searching for?
To dive even deeper into the subject, you may watch this video I have created on the topic of Variables: