Introduction to Java || Java + DSA course || Blog 1
What is your mother tongue?
It can be English, Hindi, Japanese, Russian....many more.
There are total 7000 Languages across the world for us to Communicate. But what if we want to talk to a computer?
Of course computer doesn't understand English. So what does it understand?
Computer understands a simple language called as Binary . Its script contains only 0s and 1s.It seems easy to learn but it isn't. Just to write A in binary is 01000001.
So even if we just want to do a simple thing like adding 2 numbers, it will mostly be hard enough.
Due to these issue, high level languages were invented. What are they? Think of it as a mixture of human language and computer language. Due to these languages humans could command a task to the computer easily.
One of the best and easy High level languages is Java
Java is the language which can be run on any computer having JDK.(java development kit.We will talk about it in our 2nd blog)

Lets talk about how do we give a command to a computer.
For a human its easy to say to brush his/her teeth. What about computer?
We need to know what we exactly want him to command because it doesn't know how to brush his teeth.
GOALS
1.Put toothpaste on your toothbrush
2.Keep moving brush inside and outside until all tooth are cleaned
3. Rinse your mouth with water
This is called Pseudocode. it tells you what exactly to do.
For this course we are going to use visual studio code. Download link is given in the end.
How does our Java code actually Work?
There are 2 steps:
1.Compilation
Now lets say you wrote the normal code . Back in the days , if we want to save a text file, we saved it as file '.txt' . In same way, java file is saved as file '.java'.
This code is then transferred to compiler where jdk converts it into byte code. It is saved as 'file.class'. Byte code is the reason java code can work on any device.
2.Execution
This byte code is converted into its native code(if the code was java then its converted into java class after compilation)
Now lets get to the main code....HELLO WORLD
Every programmer whenever wants to check a code to run on code editor writes this. Most peoples first code is to print hello world.
Java contains 2 main items called as classes and functions.
Functions are the group of code that can work whenever you want. Think of it as student .
Class contain various functions . Think of it as a whole classroom which has varieties of kids. One is good in drawing while other is in studies
Lets understand it word to word.
public class Main - This can be said as a class. It has given name as main which is also public. It means that other classes can have an access for this class.
public static - This can be said as a function. Public means it is visible for other classes while static means "this method returns nothing". For eg. think of a traveler who has lost his way. You help to reach his destination. You don't want anything in return. You are just helping. static means that the method is not attached to the specific instance.
void main - As the main() method doesn't return anything, its return type is void. As soon as the main() method terminates, the java program terminates too. void basically means return type
String[] args - It is just to tell the type. Here it is an array.
System.out.println - System is the final class defined in Java. 'out.println' is a java statement which prints the system. It is written inside round bracket in double inverted commas. A t the end of the function in every line, ; is written.
Save your file name as your file class name.in this case Main.java
vs code download link - https://code.visualstudio.com/download
Jdk download link - https://www.oracle.com/java/technologies/downloads/
______________________________________________________________________________
Did you like the java blog 1?
tell us in the comment section.
Nice. Excellent work 😁👍. Very nice. Very much nice.
ReplyDeleteThank u🌹🌹
DeleteNicely written
ReplyDeleteNicely explained
ReplyDeleteI am going to start DSA with your blogs
ReplyDelete