Java Void Keyword

Java Void Keyword

void Keyword In Java
Here we put void keyword before any method when we have to say that he method does not contains any return type 
The keyword void simply tells the compiler that main( ) does not return a value. As you will see, methods may also return values.
As it is a predefined keyword hence it will always be written in small case
Also in java there is a class named Void –
The Void class has one field, TYPE, which holds a reference to the Class object for type void. You do not create instances of this class.
Now we will see some Examples  - 
Example - 
This is a simple Java program.
Call this file "".
class Example {
// Your program begins with a call to main().
public static void main(String args[]) {
System.out.println("This is a simple Java program.");

Example - 
Now we will see what will happen if we try to return something with void return type of a method
import second.*;
public class Main {

  void sample(){
        int a = 10;

  return ;
  public static void main(String[] args) {
  // write your code here

      Main ob = new Main();
    int x =  ob.sample();
Output -