AddThis

Tuesday 15 January 2019

Java keywords, Java Identifiers

Java Keywords

  • Keywords are simple English words which are having predefined meaning in Java Programming Language.
  • Meaning of these keywords can't be modified.
  • Keywords are also called Reserved Words.
  • All the keywords are defined in lower case.
  • We can't use keywords as names of variables, methods, classes or as any other identifiers.
  • true, false, null are not keywords but reserved as Literals.
  • There are 49 keywords defined up to Java 2.
  • enum is new keyword add from Java 5 so there are 50 keywords from Java 5.
  • const and goto are keywords but no implementation available. You can't use these keywords in Java program.
List of Keywords
Data types (8)
byte
short
int
long
float
double
char
Boolean

Class & Object (9)
class
interface
enum
extends
implements
this
super
new
instanceof
Access Modifier (3)
private
protected
public
Modifier (9)
final
native
abstract
synchronized
transient
volatile
static
const
strictfp
Package (2)
package
import
Control Statements (12)
if
else
switch
case
default
do
while
break
for
continue
return
goto
Exception Handling (6)
try
catch
finally
throw
throws
assert
Other type (1)
void

Identifiers
  • Identifiers are the names which will be used to identify the programming elements like variable, methods, classes etc uniquely.
  • Identifiers are also known as User Defined Words.
Rules to follow when we define an identifier:
  • Identifier can contain Alphabets, Digits and two special symbols Dollar ($) and Underscore (_).
  • First character of an identifier must be an Alphabet or Dollar ($) or Underscore (_).
  • Keywords or Reserved words can't be used as Identifier.
Valid Identifier
Invalid Identifier
Hello
1stClass
Int
true
getClassName
student number
studentEmail
student-email
TOTAL_FEE
int




No comments:

Post a Comment

100 AWS Services in Just One Line Each

  100 AWS Services in Just One Line Each Amazon EC2:  Virtual servers in the cloud. Amazon S3:  Scalable object storage service. Amazon RDS:...