Chapter - 4 (IX)
Chapter - 4 (IX)
06. case 07. catch 08. char 09. continue 10. default
21. import 22. instanceof 23. int 24. interface 25. long
26. native 27. new 28. package 29. private 30. protected
31. public 32. return 33. short 34. static 35. super
36. switch 37. synchronized 38. this 39. thro 40. throws
41. transient 42. try 43. void 44. volatile 45. while
46. assert 47. const 48. enum 49. goto 50. strictfp
Identifier
• Identifiers are used to name a variable,
constant, function, class, and array.
• It usually defined by the user.
• It uses letters, underscores, or a dollar sign as
the first character.
• The label is also known as a special kind of
identifier that is used in the goto statement.
• Remember that the identifier name must be
different from the reserved keywords.
There are some rules to declare
identifiers are:
• The first letter of an identifier must be a letter,
underscore or a dollar sign. It cannot start
with digits but may contain digits.
• The whitespace cannot be included in the
identifier.
• Identifiers are case sensitive.
Valid identifiers
• PhoneNumber
• PRICE radius
• a
• a1
• _phonenumber
• $circumference
• jagged_array
• 12radius //invalid
Literals
• In programming literal is a notation that represents a fixed
value (constant) in the source code.
• It can be categorized as an integer literal, string literal,
Boolean literal, etc.
• It is defined by the programmer. Once it has been defined
cannot be changed. Java provides five types of literals are as
follows:
– Integer
– Floating Point
– Character
– String
– Boolean
Literal Type
23 int
9.86 double
"javatpoint" String
Arithmetic +,-,/,*,%
Unary ++ , - - , !
Assignment = , += , -= , *= , /= , %= , ^=
Logical && , ||
Bitwise &,|,^,~
byte 0 1 byte
short 0 2 byte
int 0 4 byte
long 0L 8 byte