How to code Java 01: What's Java?

in #blog7 years ago

Hi! This is the first tutorial to learn how to code in Java. Let's get to it!

Java is a multi platform language that allows you to do a program that can be used in different platforms without change the code (or barely change it).
Other languages, like C++, need to be compiled. This means that you need to translate your code to a sub-language that your Operating System will understand. Imagine you need to write a program to do something on Windows. You write it and you compile it for Windows. Then a person tells you "you know what? I think I want it for iOS too". And then you will have to compile it for iOS and, the most probably scenario, is that you will have to adapt your code to make it work because iOS and Windows "talk" different languages and they use different ways of understand things. Think of it as a person from USA and another from UK. One says cab, the other says taxi. It's the same thing, same language, different word. If you want your C++ code to compile, you will need to use the right word for each of them. Not with Java.

With Java you write just one program and the Java Virtual Machine translates it for everyone!
And here's is the first thing to know: in order to use a Java program in any computer, the computer needs to have the Java Virtual Machine installed. There is one of those for each platform (Windows, Linux, Mac). So you can have your program in a usb drive and use it anywhere just by installing the corresponding JVM.
In the next tutorial we will install the one you need.

Second thing you need to know is that Java is an Object Oriented Language. This means that you create objects that do things and/or have access to other objects to do more things.

Objects are a concept, a way to represent functionality. Imagine you want to create a ball. A ball has properties (adjectives) like its color, material or size. It also has functionality (verbs): it can bounce or roll. This is the kind of thing you will create in your code, an object that represent things you want to use or do.
Let's use a more "real example": you can create a cryto currency manger that will show you how your favorite crypto currency (steem of course) is doing. This object will connect t o a database, download the value of your currency and show it on your screen. It can also remember the original price you got it and show you how much have you won in the past week.

Like real life objects, we need a blueprint or a mold. This is called a Class.
The Class will have all the characteristics you need on your object so, every time you use it, you have a ball just like you want it.
Your Class to create balls will have a size, a color and some functions so the ball will do stuff you want.
Your Class to create a Crypto Currency Manager will have the url of the data base, the name of the currency you want to get info from and a function that will print the value on the screen.

How are you doing? confused? no worries, just stay tuned for the next tutorials and you will see the light at then of the tunnel!
Next lesson we will be moving what are variables and operators and how do we use them to create the properties our object will have.

Feel free to ask for a deeper explanation of to answer any doubt you might have so far!
See you soon!

Sort:  

Following you!

Congratulations @mbrp! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!

Coin Marketplace

STEEM 0.30
TRX 0.12
JST 0.032
BTC 60205.00
ETH 2994.41
USDT 1.00
SBD 3.90