First Java Program: Basic

This Java tutorial will illustrate the basics of all java programs.

class Welcome

Class is a keyword. Welcome is an identifier or name of the class.
Class Welcome is declaration of class.

class Welcome
{

}

Every class definition in Java begins with an opening brace and ends with a matching closing brace. Note that there is no ending semicolon in Java unlike in C++.

public static void main(String args[])
 {
  System.out.println("Welcome To Java!");
 }

main() is the starting point for the interpreter to begin execution of the program. A java application can have any number of classes but only one of them must include a main method.
void: since main does not return any value;
static: Java is a pure object oriented programming language and hence even main is written inside of a class. main() belongs to the entire class and not a part of any objects of the class, so main is declared as static.
public: methods with public access specification can be accessed even outside the class.

String: is a built-in class, present inside java.lang package.
args[] : is a array variable, used to get the arguments from the user.

System.out.print() or System.out.println() is similar to printf() in C or cout>> in C++.
print() or println() method is a member of the out object, which is a static data member of System class.

Full Java code to print “Welcome to Java!” (Welcome.java)

class Welcome
{
 public static void main(String args[])
 {
  System.out.println("Welcome To Java!");
 }
}

Video Tutorial


YouTube Link: https://www.youtube.com/watch?v=lXaFnboq3sk [Watch the Video In Full Screen.]


YouTube Link: https://www.youtube.com/watch?v=ePG4GE3hmbY [Watch the Video In Full Screen.]



Please watch the above video tutorial in full screen.