SlideShare a Scribd company logo
1 of 28
Download to read offline
Syntax and Data Type
Content
1. Variable declaration
2. Java Naming Rule
3. Comments
4. Primitive Data
5. Type/Wrapper Class
6. Auto Boxing
7. Promotion and Casting
8. Operators
Variable Declaration
● Variable is a name of memory location.
● Variable Declaration:
[access_modifier] Datatype varName [ = value];
● There are three types of variables in Java:
○ Instance variable
○ Class Variable or Static variable
○ Local variable
Variable Declaration
● Instance variable (non-static fields):
○ Declared outside a method, constructor, block
○ Are visible to all methods, constructors and block in the class
○ No “static” keyword
○ Values are unique to instance of class
○ Has a default value
Variable Declaration
● Static or Class variable (static fields):
○ Must be declared outside of methods
○ Has “static” keyword
○ Can be accessed by ClassName.VariableName
○ Has a default value
Variable Declaration
● Local Variables
○ Declared in a method, constructor or block
○ No access modifier
○ Lifetime is only within declared block
○ Automatically destroyed once it exits the block
○ No default value => Must be initial a value before used
○ Parameters are also local variables:
■ No access modifier
■ Used for passing a value for method
Variable Declaration
Java Naming Rules
● Variable is case-sensitive
● Can begin with letter (recommended), dollar sign ($), underscore( _ )
● Can contain letters, numbers, underscores and dollar sign (not recommended)
● Can not contain other special characters, whitespace, keywords
● Should start lowercase and with UPPERCASE for the character of the next word (eg.
teacherName)
Comments
● Describe the definition of code
● Remark the code
● Documenting the code
● Get ignored by the compiler
● There are 3 types of comments:
○ Single line
○ Multi line
○ Documents
Comments
● Single line : // (Double forward slash)
Comments
● Multi-line : /* ................ */
Comments
● Documents: /**...............*/
Primitive Data Types / Wrapper Class
Primitive Data Types
● Java defines primitive types of data into 8 types: byte, short, int, long, char, float,
double, and boolean
● Primitive Data type is divided into 4 groups:
○ Integer: byte, short, int, long - that are used for whole-valued signed numbers
○ Floating-point numbers: float and double - that is used for decimal numbers
○ Character: char - is represented for symbols in character set such as letters and
numbers
○ Boolean: boolean – is a special data type that is represented true/false values.
Primitive Data Types / Wrapper Class
● Integers and Floating-point types
●
●
●
●
● Character
Primitive Data Types / Wrapper Class
● Character
○ In Java, char data type has a size of 16-bit that is range from ‘u0000’ to ‘uffff’ or
0-65535
● Boolean
○ boolean data type has 1-Bit size that stores values of 0, 1 represented of false and
true
Primitive Data Types / Wrapper Class
Wrapper Class
● provides the mechanism for converting primitive data types to Object Wrapper Class.
● For convert data type from String to primitive data type
● provide some methods for usage
Primitive Data Types / Wrapper Class
Wrapper Class
Auto Boxing
● Autoboxing is the automatic conversion that Java compiler makes between the
primitive data types and their corresponding object wrapper class
E.g Integer i = 9; // This is autoboxing
// Compiler will replace 9 with Integer.valueOf(9)
Unboxing
● Unboxing is the automatic conversion from object wrapper class to primitive data
type
E.g
Integer i = new Integer(9);
int j = i; // This is unboxing
// int j = i; is equal to int j = i.intValue();
Promotion & Casting
Promotion
● Promotion is an automatic type conversion
● No data losing
● No casting operator
Promotion & Casting
Casting
● Casting is type conversion to a specific data type.
● But there are some points that we can not cast such as:
○ Primitive type to Reference type
○ Null value to primitive type
○ Primitive type to Boolean
○ Boolean to other primitive types
Operators
● Operator in java is a symbol that is used to perform operations
● Here are some basic operators that are commonly used:
○ Assignment Operator
○ Arithmetic Operator
○ Relational / Comparison Operator - Bitwise Operator
○ Logical Operator
Operators
● Assignment Operators
Operators
● Arithmetic Operators
Operators
● Relational Operators
Operators
● Bitwise Operators
Operators
● Logical Operators
Thank you!

More Related Content

Similar to 2._Java_Syntax_and_Data_Type.pptx.pdf

Basics of PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Basics of PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeBasics of PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Basics of PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Dhivyaa C.R
 

Similar to 2._Java_Syntax_and_Data_Type.pptx.pdf (20)

Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
JVM and OOPS Introduction
JVM and OOPS IntroductionJVM and OOPS Introduction
JVM and OOPS Introduction
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
oopm 2.pdf
oopm 2.pdfoopm 2.pdf
oopm 2.pdf
 
Enumerations in java.pptx
Enumerations in java.pptxEnumerations in java.pptx
Enumerations in java.pptx
 
Typescript
TypescriptTypescript
Typescript
 
Structured Languages
Structured LanguagesStructured Languages
Structured Languages
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 
Introduction to JavaScript
Introduction to JavaScriptIntroduction to JavaScript
Introduction to JavaScript
 
CHAPTER 3- Lesson A
CHAPTER 3- Lesson ACHAPTER 3- Lesson A
CHAPTER 3- Lesson A
 
Java data types
Java data typesJava data types
Java data types
 
enum_namespace.ppt
enum_namespace.pptenum_namespace.ppt
enum_namespace.ppt
 
06.pptx
06.pptx06.pptx
06.pptx
 
ITFT - Java
ITFT - JavaITFT - Java
ITFT - Java
 
Data Handling
Data HandlingData Handling
Data Handling
 
Basics of PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Basics of PHP by Dr.C.R.Dhivyaa Kongu Engineering CollegeBasics of PHP by Dr.C.R.Dhivyaa Kongu Engineering College
Basics of PHP by Dr.C.R.Dhivyaa Kongu Engineering College
 
UNIT 1 (7).pptx
UNIT 1 (7).pptxUNIT 1 (7).pptx
UNIT 1 (7).pptx
 
UNIT 1 (7).pptx
UNIT 1 (7).pptxUNIT 1 (7).pptx
UNIT 1 (7).pptx
 
JAVA LESSON-01.pptx
JAVA LESSON-01.pptxJAVA LESSON-01.pptx
JAVA LESSON-01.pptx
 

More from luxasuhi

Vulnerable_Populatihhhhuuuuuuons.pptx.pdf
Vulnerable_Populatihhhhuuuuuuons.pptx.pdfVulnerable_Populatihhhhuuuuuuons.pptx.pdf
Vulnerable_Populatihhhhuuuuuuons.pptx.pdf
luxasuhi
 
Telling_the_uwuwiwiajjakakaData_Story_.pptx.pdf
Telling_the_uwuwiwiajjakakaData_Story_.pptx.pdfTelling_the_uwuwiwiajjakakaData_Story_.pptx.pdf
Telling_the_uwuwiwiajjakakaData_Story_.pptx.pdf
luxasuhi
 
bad_leadershiiiiiiiiiiiiiiiiiiip.ppt.pdf
bad_leadershiiiiiiiiiiiiiiiiiiip.ppt.pdfbad_leadershiiiiiiiiiiiiiiiiiiip.ppt.pdf
bad_leadershiiiiiiiiiiiiiiiiiiip.ppt.pdf
luxasuhi
 
waves_31_jan_2akakakakakkakakka024.pptx.pdf
waves_31_jan_2akakakakakkakakka024.pptx.pdfwaves_31_jan_2akakakakakkakakka024.pptx.pdf
waves_31_jan_2akakakakakkakakka024.pptx.pdf
luxasuhi
 
289158090_Classic_Pen_Company_Case__1_.pptx.pdf
289158090_Classic_Pen_Company_Case__1_.pptx.pdf289158090_Classic_Pen_Company_Case__1_.pptx.pdf
289158090_Classic_Pen_Company_Case__1_.pptx.pdf
luxasuhi
 
pfofofooffofofofofifofifofof9f9f9ff9ptx.pdf
pfofofooffofofofofifofifofof9f9f9ff9ptx.pdfpfofofooffofofofofifofifofof9f9f9ff9ptx.pdf
pfofofooffofofofofifofifofof9f9f9ff9ptx.pdf
luxasuhi
 
healthcare_business_in_the_philippines__1_.pptx.pdf
healthcare_business_in_the_philippines__1_.pptx.pdfhealthcare_business_in_the_philippines__1_.pptx.pdf
healthcare_business_in_the_philippines__1_.pptx.pdf
luxasuhi
 

More from luxasuhi (20)

Vulnerable_Populatihhhhuuuuuuons.pptx.pdf
Vulnerable_Populatihhhhuuuuuuons.pptx.pdfVulnerable_Populatihhhhuuuuuuons.pptx.pdf
Vulnerable_Populatihhhhuuuuuuons.pptx.pdf
 
Telling_the_uwuwiwiajjakakaData_Story_.pptx.pdf
Telling_the_uwuwiwiajjakakaData_Story_.pptx.pdfTelling_the_uwuwiwiajjakakaData_Story_.pptx.pdf
Telling_the_uwuwiwiajjakakaData_Story_.pptx.pdf
 
bad_leadershiiiiiiiiiiiiiiiiiiip.ppt.pdf
bad_leadershiiiiiiiiiiiiiiiiiiip.ppt.pdfbad_leadershiiiiiiiiiiiiiiiiiiip.ppt.pdf
bad_leadershiiiiiiiiiiiiiiiiiiip.ppt.pdf
 
waves_31_jan_2akakakakakkakakka024.pptx.pdf
waves_31_jan_2akakakakakkakakka024.pptx.pdfwaves_31_jan_2akakakakakkakakka024.pptx.pdf
waves_31_jan_2akakakakakkakakka024.pptx.pdf
 
LECTURE_08_Negative_or_Bad_news_messages__1_.pptx.pdf
LECTURE_08_Negative_or_Bad_news_messages__1_.pptx.pdfLECTURE_08_Negative_or_Bad_news_messages__1_.pptx.pdf
LECTURE_08_Negative_or_Bad_news_messages__1_.pptx.pdf
 
The_Zero_Hunger_Prakoaoaoaoaoaoaoject.pptx.pdf
The_Zero_Hunger_Prakoaoaoaoaoaoaoject.pptx.pdfThe_Zero_Hunger_Prakoaoaoaoaoaoaoject.pptx.pdf
The_Zero_Hunger_Prakoaoaoaoaoaoaoject.pptx.pdf
 
Conditionnnnnnnnnnnnbbnbals_1_2_3.pptx.pdf
Conditionnnnnnnnnnnnbbnbals_1_2_3.pptx.pdfConditionnnnnnnnnnnnbbnbals_1_2_3.pptx.pdf
Conditionnnnnnnnnnnnbbnbals_1_2_3.pptx.pdf
 
289158090_Classic_Pen_Company_Case__1_.pptx.pdf
289158090_Classic_Pen_Company_Case__1_.pptx.pdf289158090_Classic_Pen_Company_Case__1_.pptx.pdf
289158090_Classic_Pen_Company_Case__1_.pptx.pdf
 
Review5tttgfd97d7s7ss6ss7s7s7ser-Mas.pptx
Review5tttgfd97d7s7ss6ss7s7s7ser-Mas.pptxReview5tttgfd97d7s7ss6ss7s7s7ser-Mas.pptx
Review5tttgfd97d7s7ss6ss7s7s7ser-Mas.pptx
 
pfofofooffofofofofifofifofof9f9f9ff9ptx.pdf
pfofofooffofofofofifofifofof9f9f9ff9ptx.pdfpfofofooffofofofofifofifofof9f9f9ff9ptx.pdf
pfofofooffofofofofifofifofof9f9f9ff9ptx.pdf
 
healthcare_business_in_the_philippines__1_.pptx.pdf
healthcare_business_in_the_philippines__1_.pptx.pdfhealthcare_business_in_the_philippines__1_.pptx.pdf
healthcare_business_in_the_philippines__1_.pptx.pdf
 
The_book_of_hhunknown_americans.pptx.pdf
The_book_of_hhunknown_americans.pptx.pdfThe_book_of_hhunknown_americans.pptx.pdf
The_book_of_hhunknown_americans.pptx.pdf
 
8.7_Lesson_Slidyyyyyyyyes_2__1_.pptx.pdf
8.7_Lesson_Slidyyyyyyyyes_2__1_.pptx.pdf8.7_Lesson_Slidyyyyyyyyes_2__1_.pptx.pdf
8.7_Lesson_Slidyyyyyyyyes_2__1_.pptx.pdf
 
final_presentatiyyyyyyyyy6666on.pptx.pdf
final_presentatiyyyyyyyyy6666on.pptx.pdffinal_presentatiyyyyyyyyy6666on.pptx.pdf
final_presentatiyyyyyyyyy6666on.pptx.pdf
 
Culture_Quwuwiqiiqiqosiaiaakaaijajajauest.pptx.pdf
Culture_Quwuwiqiiqiqosiaiaakaaijajajauest.pptx.pdfCulture_Quwuwiqiiqiqosiaiaakaaijajajauest.pptx.pdf
Culture_Quwuwiqiiqiqosiaiaakaaijajajauest.pptx.pdf
 
Native_Americans_of_North_America_PPT.pptx.pdf
Native_Americans_of_North_America_PPT.pptx.pdfNative_Americans_of_North_America_PPT.pptx.pdf
Native_Americans_of_North_America_PPT.pptx.pdf
 
Sustainable_Strategy___Jasmine_Baxter.pptx.pdf
Sustainable_Strategy___Jasmine_Baxter.pptx.pdfSustainable_Strategy___Jasmine_Baxter.pptx.pdf
Sustainable_Strategy___Jasmine_Baxter.pptx.pdf
 
Lecture_4_ohjjjjdjjn_Gear_Trains.pptx.pdf
Lecture_4_ohjjjjdjjn_Gear_Trains.pptx.pdfLecture_4_ohjjjjdjjn_Gear_Trains.pptx.pdf
Lecture_4_ohjjjjdjjn_Gear_Trains.pptx.pdf
 
Piper_arrow_landing_gear_system.pptx.pdf
Piper_arrow_landing_gear_system.pptx.pdfPiper_arrow_landing_gear_system.pptx.pdf
Piper_arrow_landing_gear_system.pptx.pdf
 
tagalog_pilipino_filipintttytyo.pptx.pdf
tagalog_pilipino_filipintttytyo.pptx.pdftagalog_pilipino_filipintttytyo.pptx.pdf
tagalog_pilipino_filipintttytyo.pptx.pdf
 

Recently uploaded

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
MateoGardella
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
heathfieldcps1
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
kauryashika82
 

Recently uploaded (20)

Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
SECOND SEMESTER TOPIC COVERAGE SY 2023-2024 Trends, Networks, and Critical Th...
 
Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.Gardella_Mateo_IntellectualProperty.pdf.
Gardella_Mateo_IntellectualProperty.pdf.
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
Ecological Succession. ( ECOSYSTEM, B. Pharmacy, 1st Year, Sem-II, Environmen...
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in DelhiRussian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
Russian Escort Service in Delhi 11k Hotel Foreigner Russian Call Girls in Delhi
 

2._Java_Syntax_and_Data_Type.pptx.pdf

  • 2. Content 1. Variable declaration 2. Java Naming Rule 3. Comments 4. Primitive Data 5. Type/Wrapper Class 6. Auto Boxing 7. Promotion and Casting 8. Operators
  • 3. Variable Declaration ● Variable is a name of memory location. ● Variable Declaration: [access_modifier] Datatype varName [ = value]; ● There are three types of variables in Java: ○ Instance variable ○ Class Variable or Static variable ○ Local variable
  • 4. Variable Declaration ● Instance variable (non-static fields): ○ Declared outside a method, constructor, block ○ Are visible to all methods, constructors and block in the class ○ No “static” keyword ○ Values are unique to instance of class ○ Has a default value
  • 5. Variable Declaration ● Static or Class variable (static fields): ○ Must be declared outside of methods ○ Has “static” keyword ○ Can be accessed by ClassName.VariableName ○ Has a default value
  • 6. Variable Declaration ● Local Variables ○ Declared in a method, constructor or block ○ No access modifier ○ Lifetime is only within declared block ○ Automatically destroyed once it exits the block ○ No default value => Must be initial a value before used ○ Parameters are also local variables: ■ No access modifier ■ Used for passing a value for method
  • 8. Java Naming Rules ● Variable is case-sensitive ● Can begin with letter (recommended), dollar sign ($), underscore( _ ) ● Can contain letters, numbers, underscores and dollar sign (not recommended) ● Can not contain other special characters, whitespace, keywords ● Should start lowercase and with UPPERCASE for the character of the next word (eg. teacherName)
  • 9. Comments ● Describe the definition of code ● Remark the code ● Documenting the code ● Get ignored by the compiler ● There are 3 types of comments: ○ Single line ○ Multi line ○ Documents
  • 10. Comments ● Single line : // (Double forward slash)
  • 11. Comments ● Multi-line : /* ................ */
  • 13. Primitive Data Types / Wrapper Class Primitive Data Types ● Java defines primitive types of data into 8 types: byte, short, int, long, char, float, double, and boolean ● Primitive Data type is divided into 4 groups: ○ Integer: byte, short, int, long - that are used for whole-valued signed numbers ○ Floating-point numbers: float and double - that is used for decimal numbers ○ Character: char - is represented for symbols in character set such as letters and numbers ○ Boolean: boolean – is a special data type that is represented true/false values.
  • 14. Primitive Data Types / Wrapper Class ● Integers and Floating-point types ● ● ● ● ● Character
  • 15. Primitive Data Types / Wrapper Class ● Character ○ In Java, char data type has a size of 16-bit that is range from ‘u0000’ to ‘uffff’ or 0-65535 ● Boolean ○ boolean data type has 1-Bit size that stores values of 0, 1 represented of false and true
  • 16. Primitive Data Types / Wrapper Class Wrapper Class ● provides the mechanism for converting primitive data types to Object Wrapper Class. ● For convert data type from String to primitive data type ● provide some methods for usage
  • 17. Primitive Data Types / Wrapper Class Wrapper Class
  • 18. Auto Boxing ● Autoboxing is the automatic conversion that Java compiler makes between the primitive data types and their corresponding object wrapper class E.g Integer i = 9; // This is autoboxing // Compiler will replace 9 with Integer.valueOf(9)
  • 19. Unboxing ● Unboxing is the automatic conversion from object wrapper class to primitive data type E.g Integer i = new Integer(9); int j = i; // This is unboxing // int j = i; is equal to int j = i.intValue();
  • 20. Promotion & Casting Promotion ● Promotion is an automatic type conversion ● No data losing ● No casting operator
  • 21. Promotion & Casting Casting ● Casting is type conversion to a specific data type. ● But there are some points that we can not cast such as: ○ Primitive type to Reference type ○ Null value to primitive type ○ Primitive type to Boolean ○ Boolean to other primitive types
  • 22. Operators ● Operator in java is a symbol that is used to perform operations ● Here are some basic operators that are commonly used: ○ Assignment Operator ○ Arithmetic Operator ○ Relational / Comparison Operator - Bitwise Operator ○ Logical Operator