Java Keywords

These are the important keywords in java programming language.

Keywords are special reserved words in java .They have meaning to the compiler, it uses them to understand what your source code is trying to do.

1. abstract
     It is an class in java programming. it may be or not include the abstract methods.
     eg :- 

    public abstract class GraphicObject {
   // declare fields
   // declare nonabstract methods
   abstract void draw();
}


2.  assert
     This assert is used to take an assumptions in that code to fix bugs. it's a Boolean condition. 
  Simple Syntax 
assert expression1 : expression2;


3. boolean
    This boolean keyword is used for declare two possible values, such as True / False

private boolean initialized = false;

public void synchronizeConnection() {
if (!initialized) {
      connection = connect();
      initialized = true;
}
}

4. break
   This keyword is used for to break the loop
 eg :-
for ( int i=0; i < maxLoopIter; i++ ) {
   System.out.println("Iter=" +i);
   if ( i == 5 ) {
      break;  // -- 5 iteration is enough --
   }
}

5. byte
  It is 8bit integer data type.
eg:-  Basic Syntax 
byte = ;

byte a=10;

6. case
this keyword is used for the decision making or control the flows of program.
eg:- public class SwitchDemo {
    public static void main(String[] args) {

        int month = 2;
        String monthString;
        switch (month) {
            case 1:  monthString = "January";
                     break;
            case 2:  monthString = "February";
                     break;
            case 3:  monthString = "March";
                     break;
            case 4:  monthString = "April";
                     break;
            case 5:  monthString = "May";
             
        }
        System.out.println(monthString);
    }
}
7. catch
   This catch keyword is used for the java exception handling  and used with 'try'.
eg:- try {
   //...
     throw new MyException_1();
   //...
} catch ( MyException_1 e ) {
   // --- Handle the Exception_1 here --
} catch ( MyException_2 e ) {
   // --- Handle the Exception_2 here --
}

8. char
this char is about the characters.this keyword is used for the character variables.

9. class
keyword class to declare that a new class is being defined.

10. const
Const  has no function.[For defining constants in java, see the 'final' reserved word.

11. continue
this keyword is used for to re-execute the conditions such as while,do loop.
eg:- while (getNext(line)) {
  if (line.isEmpty() || line.isComment())
    continue;
  // More code here
}
12. default
this keyword is enable the interface functionality of the library.
13. do
The do keyword is used in conjunction with while to create a do-while loop.
do {
     statement(s)
} while (expression);

14. double
  This keyword is used to declare a numeric value
public class DoubleDemo { 
  public static void main(String[] args) { 
  double area = 6.15;
  System.out.print("Area: ");
  System.out.print(area);
  }
}


15. else
It  is used for compare the boolean values in java programming
void applyBrakes() {
    if (isMoving) {
        currentSpeed--;
    } else {
        System.err.println("The bicycle has already stopped!");
    } 
}

16. enum
       this enum keyword is for predefined the constants.
public enum Day {
    SUNDAY, MONDAY, TUESDAY, WEDNESDAY,
    THURSDAY, FRIDAY, SATURDAY 
}

17. extends
it can use for the many classes in java language.
public class Bicycle {
        
    // the Bicycle class has three fields
    public int cadence;
    public int gear;
    public int speed;
        
    // the Bicycle class has one constructor
    public Bicycle(int startCadence, int startSpeed, int startGear) {
        gear = startGear;
        cadence = startCadence;
        speed = startSpeed;
    }
        
    // the Bicycle class has four methods
    public void setCadence(int newValue) {
        cadence = newValue;
    }
}
18. final
Define an entity once that cannot be changed nor derived from later. More specifically: a final class cannot be subclassed, a final method cannot be overridden, and a final variable can occur at most once as a left-hand expression
19. finally
this keyword is execute the try blocks in java
eg:- finally {
    if (out != null) { 
        System.out.println("Closing PrintWriter");
        out.close(); 
    } else { 
        System.out.println("PrintWriter not open");
    } 
} 


20. float
The float  keyword is used to declare a variable that can hold a 32-bit single precision IEEE 754 floating-point number
float b = 3.6f;
21. for
The for keyword is used to create a for loop, which specifies a variable initialization, a boolean expression, and an incrementation

22. goto
It has no value but it's a reserved word.
IF condition THEN goto label

The if keyword is used to create an if statement, which tests a boolean expression; if the expression evaluates to true, the block of statements associated with the if statement is executed.

24. implements
Included in a class declaration to specify one or more interfaces that are implemented by the current class

25. import
normally import is used by the compiler to identify the class.
eg:- import.java.util.Scanner

26. instanceof
binary operator that takes an object reference as its first operand and a class or interface as its second operand and produces a boolean result

27. int
this is primitive data   type in java language. it is a integer.
eg:- // The number 26, in decimal
int decVal = 26;
//  The number 26, in hexadecimal
int hexVal = 0x1a;
// The number 26, in binary
int binVal = 0b11010;

28. interface
Used to declare a special type of class that only contains abstract methods, constant (static final) fields and static interfaces
interface Bicycle {

    //  wheel revolutions per minute
    void changeCadence(int newValue);

    void changeGear(int newValue);

    void speedUp(int increment);

    void applyBrakes(int decrement);
}
29. long
The long keyword is used to declare a variable that can hold a 64-bit signed two's complement integer

30. native
Used in method declarations to specify that the method is not implemented in the same Java source file, but rather in another language

31. new
Used to create an instance of a class or array object.

32. package
A group of types. Packages are declared with the package keyword.

33. private
The private keyword is used in the declaration of a method, field, or inner class.

34. protected
The protected keyword is used in the declaration of a method, field, or inner class; protected members can only be accessed by members of their own class, that class's subclasses or classes from the same package

35. public
The public keyword is used in the declaration of a class, method, or field; public classes, methods, and fields can be accessed by the members of any class

36. return
Used to finish the execution of a method. It can be followed by a value required by the method definition that is returned to the caller

37. short
The short keyword is used to declare a field that can hold a 16-bit signed two's complement integer
short length = 20120;
public short getLength() {
    return 20120;

}

38. static
Used to declare a field, method, or inner class as a class field. Classes maintain one copy of class fields regardless of how many instances exist of that class.
class Student8{
 int rollno;
String name; 
static String college ="ITS"
Student8(int r,String n){
rollno = r;
name = n; 
}
39. strictfp
A Java keyword used to restrict the precision and rounding of floating point calculations to ensure portability

40. super
Used to access members of a class inherited by the class in which it appears. Allows a subclass to access overridden methods and hidden members of its superclass.

41. switch
The switch keyword is used in conjunction with case and default to create a switch statement, which evaluates a variable, matches its value to a specific case , and executes the block of statements associated with that case

42. synchronized
Used in the declaration of a method or code block to acquire the mutex lock for an object while the current thread executes the code

43. this
Used to represent an instance of the class in which it appears. this can be used to access class members and as a reference to the current instance

44. throw
45. throws
Used in method declarations to specify which exceptions are not handled within the method but rather passed to the next higher level of the program.
46. transient
47. try
Defines a block of statements that have exception handling. If an exception is thrown inside the try block, an optional catch block can handle declared exception types. 

48. void
The void keyword is used to declare that a method does not return any value
49. volatile
Methods, classes and interfaces thus cannot be declaredvolatile, nor can local variables or parameters.
50. while
The while keyword is used to create a while loop, which tests a boolean expression and executes the block of statements associated with the loop if the expression evaluates to true, this continues until the expression evaluates to false.