Core Java Programming Language
WHAT IS A PROGRAMMING LANGUAGE?
In the beginning
we should understand what the programming language is. Programming language is almost the same as the other languages.
Java has something like the human brain.Its name is “Software Development Kit”
WHY JAVA?
We can learn java
Java is very easy to learn but if you don’t practice you will not be able to type any code.
Any code in Java can work on every platform. (Mac, Windows, etc..)
There are many programming languages in the world. The most common ones are Java, Python, and C#. But among those, Java is the most common one in the USA and Europe, as well. After learning Java, learning Python will take a couple of weeks. WHY? Because the logic is completely the same just the syntax will be different.
WHAT IS OBJECT-ORIENTED PROGRAMMING?
When doing an application in java
developers create perfect objects and then assign some tasks to them through typing codes. They do all tasks perfectly because they are perfect. That is, creating objects depends on developers. For this reason, while doing an app in OOP; assigning tasks and testing it is so easy.
VARİABLES and METHODS
When you decide to create any object in real life
you should focus on two things: 1. Passive Characteristics 2. Active Characteristics.
As is in real life, while creating an “Object”, you should focus on these two characteristics in Java, too. Passive characteristics are called “Variables” in Java. Active characteristics are called “Methods” in Java. Instead of “Method”, sometimes “Function” is used, too. When you talk about an “Object”, you should talk about two main things. The first one is “Variables” and the second one is “Methods”.
ABOUT OOP!
WHY TO USE OOP?
In Starbucks, employees are not important because it created a perfect system. Even a kid can prepare perfect coffee. But in a traditional restaurant (“Turkish Pide Restaurant”) if the cooker is perfect, the pide will be perfect. In real life, the procedural system is the best but in coding, OOP is the best because it is possible to easily create perfect objects for developers. Perfect objects will do perfect tasks. Because of that, in Java, we prefer Object-Oriented Logic.
OBJECTS & APPLICATION
HOW TO CREATE AN OBJECT&CLASS (Theoretical) In
In real life
if you are asked to create a coin, you will need a template. If you have that template, it will be very easy to create the object. Without that template, it will be so difficult to create that object with many details. This is the same in Java. When you decide to create an object, you should create a template at the beginning.
In real life, we name it a template, in Java; we will name it a class. When we tell about the class we should understand templates to create objects. At this point, let’s glance at the application flow in Java once again.
JAVA APPLICATION
HOW TO CREATE A CLASS?
You should type 4 things to create a class:
1. Access Modifier: In real life, everything has an access modifier. For example, my driving license is my privacy. Just I can access it. A driving license has an access modifier on it. Your house has an access modifier. Just you and your family can access your house. Anyone cannot come or use your house. Or a public library in your city; it has an access modifier on it. Everyone in the city can use it.
In Java, everything you create should have an access modifier. When you create a class, you should tell who can use it. It might be used by anyone in the project or just by a single person. You should declare it through access modifiers. In Java, we have four access modifiers.
2. Keyword: It is mandatory when you want to create a class, of course, you should tell Java you want to create a class. Otherwise, how can Java know you want to create a class?
3. Name of the Class: When you create a class, you have to put a name for it just as in real life. Whichever name you want, you can put it. There is no restriction. But to name a class there are two main rules to follow. Otherwise, your code will not be readable.
The name should be related to the concept.
Every word in the class name should start in uppercase.
4. Class Body: You type variables and methods between the Curley braces.
HOW TO CREATE A METHOD IN A CLASS
- Access Modifier
- Return Type
- Method Name
- Method Parenthesis
- Method Body:
AN ADDITION METHOD INSTANCE
we need to type “Access Modifier”. We will make it “public” because addition is needed many times for many tasks.
we need to type “Return Type.” Since this is an addition operation it will give me a number. So our return type will be “int” (integer).
We can name it “add”. This name is compatible with the function of our method.
open-close parenthesis ( ).
we should put open-close Curley braces. { }.
we should fill inside the method parenthesis. When you do addition, you will need numbers. So you should give at least two numbers to it by typing inside “Method parenthesis” for example as (int a, int b).
between the Curley braces; you will type {return a+ b}