Episode 8: The if .. else statement
In this episode I will show you one of the most common uses of the boolean type: the if .. else statement. It will be an occasion to see the relational operators that apply to numbers and return a boolean result. Open Eclipse and let’s go.
The if .. else statement
Look at the following program :
1 2 3 4 5 6 7 8 9 10 11 12 | public class Main { public static void main(String[] argv) { int n= 56; if(n > 0) { System.out.println("n is positive"); } } } |
Episode 7: Primitive types
Welcome back to Java tutorials. In this episode you will return back to Eclipse and start coding in Java again. At the end of this episode, Java primitive types will have practically no secrets for you. I suppose that you are now quite armed with a good knowledge of binary numbers to attack this episode. Anyway, you always have Episode 6 in case you have something to clarify or questions to ask regarding numeral systems and base-2 system in particular. So feel confident and let’s go. Continue reading …
Episode 6: Representing numbers on computers
Greetings dear Java programmer. You are now quiet familiar with Java arithmetic operators, and you know how they can be applied to int variables and literals. In this episode you will learn how numbers are represented on a computer. This constitutes the base in order to understand how the majority of Java primitive types work. So prepare a paper and a pencil, and follow me step by step trying to reproduce all the computations by yourself. I know you can do it :mrgreen:. Continue reading …
Episode 5: Arithmetic operators
Hello dear programmer. You have seen in a previous episode how to declare, initialize, modify and display an int variable. In that episode we have talked about one arithmetic operator: the addition operator. This episode is the continuation: you will see the rest of the arithmetic operators and the precedence rules that govern them. Fasten your seat belt and get ready Continue reading …
Episode 4: Strings and concatenation
Welcome back to this new episode in this series of tutorials dedicated to programming, and more specifically programming using the amazing Java language. In the last episode we saw how to declare, initialize, modify, sum and display integer variables. In this episode we will learn how to declare, display and use one of the most important types in Java: the String type. Let’s go. Continue reading …
Episode 3: How to declare and use an integer variable ?
Welcome dear friend to the world of Java programming. In the last episode you have prepared the environment to start coding in Java and you wrote and executed your first Java program. This episode marks the real beginning of learning Java and programming. At the end of this episode you will be able to declare integer variables, print their values and use the addition operator on them. So launch Eclipse and get ready for the takeoff :mrgreen:. Continue reading …
Episode 2: Preparing the environement
Hello dear friend, it looks like this is a perfect day to start programming. In this episode you will prepare your machine for using Java and write your first Java program. The installation and configuration will be the least fun part of this episode and probably of all the upcoming ones, but don’t worry, if you follow the steps carefully it will be as easy as pie, and you’ll be able to finally enjoy coding :). Continue reading …
Episode 1: Introduction to programming
Hello dear friend, welcome to this series of very easy tutorials for learning programming in the Java programming language.
What are the prerequisites and skills I need to have to follow these tutorials ?
Does the word Programming scare you ? Have you ever heard rumors saying that programming is difficult, or that in order to be a programmer you have to be a computer science engineer, a PhD in computer science or some sort of genius ? Guess what, that rumors are completely false and maybe they are spread in the sole goal of discouraging people from learning the beautiful art of Programming. Programming is, above all, a pleasure, a game, something fun. All you need to have prior to following these tutorials is a computer, and a little logical thinking. So it’s really not a big deal.
what is programming ?
Imagine that the computer is a person. Then programming is nothing more than telling the computer what to do by giving him a list of orders or instructions that he must execute.
Obviously, if you want the computer to execute your instructions you must provide them in a language that he can understand, so something like:
Please compute the sum of 59 and 41
Is totally incomprehensible gibberish for the computer and even the most kind words and polite expressions will not be of any help for him to understand what you want him to do.
There is a thing to know about computers: although they can store a lot of information and do a lot of calculations in less than a second they are still dump and have practically no intelligence: they can’t do anything unless they are told to do it, they have no imagination and can’t learn from their mistakes. That is why you, dear friend, are going to be the master of this beast called a computer, and you are going to use it for your own benefit and take advantage of it’s capabilities.
How can I program ?
Like said before, in order for the computer to understand your commands and instructions, you have to provide them in a language that he knows. The fact is that your computer can’t understand English, Spanish, Chinese or any other human language. These languages are simply too complicated for your computer. In fact, the native language of your computer is called binary language which is based on series of Ones and Zeros looking like the following :
10011100111110110010101…
But this time, it’s us, humans, who consider the above as incomprehensible gibberish :). This is what we call a low-level programming language because it is closer to the machine than to the human.
The good news are that you don’t have to learn low-level programming languages in order to program. Computer scientists have developed for you an easier and more elegant way to talk to your computer. This is what we call high-level programming Languages. These are languages which are close to the human language (English in most cases) and which are simply translated to binary language using programs called Compilers and Interpreters.
Even better, in this series of tutorials we are going to learn one of the most awesome programming languages out there: the Java programming language.
My story with programming languages
When I was in engineering school, they left Java for the end. They started by teaching us Pascal for two weeks pretending that Pascal is a good pedagogical way to introduce us to programming. Then they taught us C for a very long period using it to teach us all the basics of programming. They taught us, in parallel to C, an Assembly language (which is a low-level programming language). They also taught us SQL for databases, Scheme and Lisp for artificial intelligence but kept the most important and demanded programming language for the end. Languages like C#.NET, HTML, CSS, XML, PHP were not taught at all we had to learn them by ourselves. Of course our professors did all of that for our benefit. But I strongly disagree with them on the order of the taught languages. If I had the choice, I would have definitely started with Java, learning all the basics of programming in Java simply because it is a clear, simple, clean, elegant and powerful language.
What can I expect from these tutorials ?
Do expect that your programming level will go up progressively starting from zero. With every tutorial you will learn a new trick and practice it by yourself
An important property of Java is that it is a C-like or C-based programming language. This means that once you learn Java, learning the other C-like languages will be simply a peace of cake. The C-like family contains languages like C, C++, C#, PHP, Perl and many others which all share a similar syntax.
What is next ?
In the next episode you will be able to write your first Java program (oh yeah !). I do believe that the best way to learn is by doing things yourself in parallel to the theoretical stuff.
See you in next episode.