Skip to main content

The basics you need to know about Java Programming Language

 

JAVA- Beginners need to know

The basics you need to know about Java Programming Language








Hello everyone, you are new to Java, This article is for you. This article great place to start learning JAVA. Let’s start

What is the JAVA?

Java is a Programming Language and platform-independent. It’s friendly syntax, object-oriented and has strong memory management and portability.

The history of Java is very interesting. Read the history of Java by following the Link Click here — History of Java.

Platform: Any hardware or software environment in which a program runs is known as a platform.

Java code can run on a variety of platforms, such as Windows, Linux, Sun Solaris, Mac OS, and others.

You can understand more about it. Let’s see How the way Java Works

Step 1: Create a source code file. (with the .java extension)

Source code means to hold on to class definition. class represent a piece of the program. the class has one or more methods. for example, In the student class has the walk method which instructions for how students should walk. keep in mind that your method must be declared inside a class. The method that how to instruction be performed. Method Code is basically a set of statements and you can think of a method kind of like a function. I will explain more about it in this article.

Step 2: Compile the source code which means Compiler runs the source code. The compiler will not allow you to compile until it is satisfied that everything will run correctly.

Step 3: In this step Compiler will return “Java bytecode” which means Java will be able to this translate/interpret file something to can run.

Step 4: Finally Java Virtual Machine(JVM) reads and runs bytecode and gives a real output from the program on the target platform.

I hope you basic understand in how to Java works.


Structure of Java Code

In this section you will learn how to write the simple code of Java applications.

First you need to install the JDK and set the path in your Machine.

Java application has to have at least one class and at least one main method (not one main per class; just one main per application). When the JVM starts running, The main method with class runs code line by line.

Here is the basic syntax for Java Class.

public class class_name{ 
public static void main (String args[]){
//statements
}
}

In this above code, It always has to be a pair of curly braces ({}).

Let’s create a Hello programme

public class Student{ 
public static void main (String args[]){
System.out.println("Hello");
}
}

Create the above program in text editor.

Save the above file Student.java
open Cmd and set the path on location on your save program
To Complie — javac Student.java
To Run — java Student

Output — Hello

In the following picture, the explanation of the class and the main method.


                                          Bates and Sierra, 2005

Conclusion

I hope, in this article, you can get the basic knowledge about Java, basic Java code Structure. I will cover Java in upcoming articles. Stay on with me.

Popular posts from this blog

How Object Behave?

  How Object Behave? Photo by Ellen Qin on  Unsplash Hello everyone, In This article, you will learn about how the state and how to relate to one another. We know about objects and variables. I give you a small reminder class that describes what an object knows and what an object does. A class is not an object. The object is used to create a class. It tells the JVM how to make an object of that particular type. Each object made from that class can have a value for the instance variable. Bates and Sierra, 2005 if you want to remind read my article first. links are here - A Trip to Objects and Classes , Know your Variables . It will help you. you already know that every object of that type can have a different instance variable. what about the method? Can objects of that type have different method behaviour? Every instance of a class has the same methods, but depending on the value of the instance variables, the methods can behave differently. Look at this example. Do...

you better understand Java primitives and references

  Know Your Variables you better understand Java primitives and references Hello everyone, Today you will learn about what is primitives and references. Variables The variable is container holds the value while the Java program is executed. you have used variables in two places. The first one is the instance variable other one is the local variable. Later we will use variables as an argument and as a return type. you have seen the variable declare as a primitive type. Declaring the Variable Let’s see how to declare the variable. Variable must have the type and the name. Don’t mess up. you will understand it while you reading the article till the end. Let’s see what is the Primitive Datatypes The different sizes and values that can be stored in the variable are defined by data types. Data types have two types. primitive data types — These include boolean, char, byte, short, int, long, float and double. non-primitive data types — These include Classes, Interfaces, and Arrays. Data Ty...