Java Keywords:
It is very important to know about the Java keywords before you go to develop Java program. These keywords are part and parcel of Java program. In this article I will introduce you with some Java keywords. There are almost 50 keywords in java. Some of them are explained below:
Class: It is used to define an implementation of a particular kind of object. A class can have class fields, methods and inner classes.
Import: This keyword is used at the beginning of a source file( before class ) to import classes or even entire java packages.
Public: It is used to declare methods and fields public.
Static: It is used to declare a field, method or inner class as a class field.
Void: It is used to declare a method that does not return any value.
Double: It is used to declare a double field. A double is primitive data type that is capable of storing decimal number.
Int: Int is a primitive data type that is capable of storing a 32-bit whole number.
If: It is used to create an if statement. The if statement test a boolean expression.
Case: This keyword is used to create individual individual cases in a switch statement.
Switch: The switch keyword is used in conjunction with the case and default keywords. It evaluates a variable and matches it to a specific case.
Else: It is used in conjunction with the if keyword to create an if-else statement.
While: It is used to create a while and do-while loop, which tests a boolean expression and keeps running the same block of code until the boolean expression returns false.
Private: It is used to declare methods and fields private.
Boolean: A boolean is a primitive data type that can store only two values: true or false.
Break: Break is used to immediately breakout of the loop or switch statement it is inside of.
Abstract: It is used to declare a class or method abstract.
Assert: This keyword was added in J2SE 1.4 and is used primarily in the debugging phase of programming.
Byte: This keyword is a primitive data type that is capable of storing 8-bit whole number.
Float: It is a primitive data type that is capable of storing a 32-bit floating point number ie, decimal number.
For: It is used to create a for loop. There are three parts of a for loop- initialization, boolean expression and incrementation.
Throw: It is used to throw an expression.This causes execution to continue with the first enclosing exception handler by the catch keyword.
Catch: It is used with the try keyword to handle an exceptions thrown within the try block.
Try: Try keyword is used in conjunction with the catch keyword to handle exceptions. I f an exception is thrown inside the try block, a catch block can handle the exceptions within the method.
Long: It is used to declare a long field. Long is a primitive data type that is capable of storing a 64-bit whole number.
Final: This keyword is used to to define an entity once and only once.
Do: It is used in conjunction with the while keyword to create a do-while loop.
New: New keyword is used to create a new instance of an array or object.
Default: This default keyword is used in a switch statement. The block of statements in the default case is executed if the value doesn't match any other case.
Continue: It is used in a loop to resume program execution.
I have introduced a very few Java keywords here, but I will try to show you how these keywords work with examples and video tutorials in upcoming Java programming article. Until then keep eyes on this blog.
It is very important to know about the Java keywords before you go to develop Java program. These keywords are part and parcel of Java program. In this article I will introduce you with some Java keywords. There are almost 50 keywords in java. Some of them are explained below:
Class: It is used to define an implementation of a particular kind of object. A class can have class fields, methods and inner classes.
Import: This keyword is used at the beginning of a source file( before class ) to import classes or even entire java packages.
Public: It is used to declare methods and fields public.
Static: It is used to declare a field, method or inner class as a class field.
Void: It is used to declare a method that does not return any value.
Double: It is used to declare a double field. A double is primitive data type that is capable of storing decimal number.
Int: Int is a primitive data type that is capable of storing a 32-bit whole number.
If: It is used to create an if statement. The if statement test a boolean expression.
Case: This keyword is used to create individual individual cases in a switch statement.
Switch: The switch keyword is used in conjunction with the case and default keywords. It evaluates a variable and matches it to a specific case.
Else: It is used in conjunction with the if keyword to create an if-else statement.
While: It is used to create a while and do-while loop, which tests a boolean expression and keeps running the same block of code until the boolean expression returns false.
Private: It is used to declare methods and fields private.
Boolean: A boolean is a primitive data type that can store only two values: true or false.
Break: Break is used to immediately breakout of the loop or switch statement it is inside of.
Abstract: It is used to declare a class or method abstract.
Assert: This keyword was added in J2SE 1.4 and is used primarily in the debugging phase of programming.
Byte: This keyword is a primitive data type that is capable of storing 8-bit whole number.
Float: It is a primitive data type that is capable of storing a 32-bit floating point number ie, decimal number.
For: It is used to create a for loop. There are three parts of a for loop- initialization, boolean expression and incrementation.
Throw: It is used to throw an expression.This causes execution to continue with the first enclosing exception handler by the catch keyword.
Catch: It is used with the try keyword to handle an exceptions thrown within the try block.
Try: Try keyword is used in conjunction with the catch keyword to handle exceptions. I f an exception is thrown inside the try block, a catch block can handle the exceptions within the method.
Long: It is used to declare a long field. Long is a primitive data type that is capable of storing a 64-bit whole number.
Final: This keyword is used to to define an entity once and only once.
Do: It is used in conjunction with the while keyword to create a do-while loop.
New: New keyword is used to create a new instance of an array or object.
Default: This default keyword is used in a switch statement. The block of statements in the default case is executed if the value doesn't match any other case.
Continue: It is used in a loop to resume program execution.
I have introduced a very few Java keywords here, but I will try to show you how these keywords work with examples and video tutorials in upcoming Java programming article. Until then keep eyes on this blog.
0 comments:
Post a Comment