News

Saturday, September 25, 2021

02 || First Program "Hello World" || Java Full Course via Netbeans

Java Full Course via Netbeans

02 || First Program "Hello World"



1. Brief Introduction:

James Gosling developed Java at Sun Microsystems Inc in 1991, later obtained by Oracle Corporation. It is a basic programming language. Java makes composing, ordering, and troubleshooting programming simple. It is used in making reusable code and modular projects.

Java is a class-based, object-oriented programming language and is designed to have as few execution conditions as could be. A broadly useful programming language made for engineers to compose once run anyplace that is compiled Java code which run on all devices that support Java. Java applications are accumulated to byte code that can run on any Java Virtual Machine. The sentence structure of Java is same as of C and C++.

2. Brief History:

Java's history is extremely interesting. This programming language was made in 1991. James GoslingMike Sheridan, and Patrick Naughton, a group of Sun engineers known as the Green Team started the Java language in 1991. Sun Microsystems delivered its first public implementation in 1996 as Java 1.0. It gives no-cost run-times on well known platforms. Java1.0 compiler was re-written in Java by Arthur Van Hoff to strictly conform to its particulars. With the appearance of the Java 2, new versions had various configurations worked for various sorts of platforms.

3. Java programming language is named JAVA. Why?

After the name OAK, the group decided to give another name to it and the recommended words were Silk, Jolt, revolutionary, DNA, dynamic, etc.  These all were easy to spell and pronounce, yet they needed the name which represents substance of technology. As per James Gosling, Java the among the top names alongside Silk, and since java was an unique name so the majority of them favored it.



Java is the name of an island in Indonesia where the first coffee(named java coffee) was delivered. What's more, this name was picked by James Gosling while at the same time having espresso close to his office. Note that Java is only a name, not abbreviation.

4. Brief Features:

Following are the main features of Java that you must know:

4.1. Platform Independent:  

Compiler changes source code to bytecode and afterward the JVM executes or runs it. This bytecode can run on any platform whether it's Windows, Linux, macOS which implies if we compile a program on Windows, then we can run it on Linux and the other platforms as well. Each OS has an alternate JVM, yet the output created by all the OS is similar after the execution of bytecode.

4.2. Object-Oriented Programming Language:  

Arranging the program in the terms of collection of objects is a method of object-oriented programming, every one of which represents instance of the class. 

The four principle ideas of Object-Oriented programming are: 
  • Abstraction
  • Encapsulation
  • Inheritance
  • Polymorphism

4.3. Portable: 

As we aware, java code composed on one machine which then can be run on another machine or Operating Systems. The platform-independent quality of java in which bytecode can be taken to any OS  for execution, makes java a versatile or portable.


5. Writing a “HELLO WORLD” Program in Java:

5.1. Input of Program:


// Basic Java Netbeans Program // to print "Hello World" import java.io.*; // Header to use System.out or System.in public class Hello_World // Class with filenam { public static void main(String[] args) { // prints Hello World System.out.println("Hello World"); } }

5.2. Output of Program:

run:

Hello World

BUILD SUCCESSFUL (total time: 0 seconds)

5.3. Explanation of Program:

5.3.1. Comments: 

Comments are utilized for clarifying or explaining code and utilized along these lines in Java or C or C++ or any other language. Compilers overlook or ignores these comments passages and don't execute them. There are two types of comments:

5.3.1.1. Single line Comments:

Syntax: 

We use double slash // in-front of line which to be commented as below:

// Single line comment

5.3.1.2. Multi line Comments:

Syntax:

We use /* in start and */ at end of lines which to be commented as below:

/* Multi line comments*/

5.3.2. Import java.io.*: 

By it we are actually importing all classes of java.io library of java. The Java.io. library gives a bunch of input and output streams for reading and writing information or data into documents or in any other input output sources.

5.3.3. Class, Object & Functions: 

The class contains the information and methods or objects to be utilized in the program. It is the collection of specific objects related to overall one main category or class i.e. plumber have many his tools in which plumber is a class and tools are his objects. Functions (like void main()) display or return the behavior of the objects. Class GFG has just a single function Main.

5.3.4. Static in Void Main(): 

The keyword static describe us that this function (main) is available without importing the class. Means it doesn't need to write its class in order to use that function in which this keyword is used. Since generally in java we  need class to use its functions. 

5.3.5. Void in Void Main(): 

This keyword void tells that this function (main) will not return anything back as output to that place from where it was called.. The main() function is the starting section of our code or application from where code start executing line by line.

5.3.6. System.in: 

It is the object of java.io.* library. This is the standard input stream that is utilized to peruse or read user input by from the console or any other standard input gadget like keyboard or digital pen, touch screen etc.

5.3.7. System.out: 

It is the object of java.io.* library. This is the standard output stream that is utilized to deliver the consequence or result of a program on a output gadget like the PC screen.

5.3.8. Println(): 

The println() object or method in Java is used to show text on console screen of computer for the user. It prints the text on the screen and after all text the cursor moves to the beginning of the following line at the console screen. The following printing will display from the next line.




No comments:

Post a Comment