SlideShare a Scribd company logo
1 of 21
Internet Technologies
Jigar Jobanputra
JAVA Program Structure
JAVA Tokens
• A java program is basically a collection of classes.
• A class defined by a set of declaration statement and methods containing
executable statements.
• Most statements contain expression, which describe the actions carried
out on data.
• Smallest individual units in program are known as tokens.
• The compiler recognizes them for building up expression and statements.
• In simple terms, a java program is a collection of tokens, comments and
white spaces.
• Java language includes five types of tokens, they are
– Reserved Keywords
– Identifiers
– Literals
– Operators
– Separators
Keywords
• Keywords are essential part of a language definition. They implement
specific features of the language. Java language has reserved 50 words
as keywords.
Identifiers
• Identifiers are programmer-designed tokens. They are used for naming
classes, methods, variables, objects, labels, packages and interfaces in a
program. Java identifiers follow the following rules:
• Variables are nothing but reserved memory locations to store values.
This means that when you create a variable you reserve some space in
memory.
– They can have alphabets, digits, and the underscore and dollar sign
characters.
– They must not begin with a digit.
– Uppercase and lowercase letters are distinct.
– They can be of any length.
Data type supported by JAVA
• There are two type of data types available in JAVA
– Primitive Data types
– Reference/Object Data types
Primitive Data Types
• byte
• short
• int
• long
• float
• double
• boolean
• char
byte
• Byte data type is a 8-bit signed two’s compliment integer.
• Minimum value is -128 (-2^7)
• Default value is 0
• Byte data type is used to save space in large arrays, mainly in place of
integers, since a byte is four times smaller than an int.
• Example: byte a = 100, byte b = -50
Short
• Short data type is a 16 bit signed two’s complement integer.
• Minimum value is -32,768(-2^15)
• Maximum value is 32,767 (2^15-1)
• Short data type can also used to save memory as byte data type. A short
is 2 times smaller than an int.
• Default value is 0.
• Example: short s=10000, short r=-20000
int
• int data type is a 32-bit signed two’s complement integer.
• Minimum value is -2,147,483,648.(-2^31)
• Maximum value is 2,147,483,647.(2^31-1)
• int is generally used as the default data type for integral values unless
there is a concern about memory.
• The default value is 0.
• Example: int a = 100000, int b = -200000
long
• long data type is 64-bit signed two’s complement integer.
• Minimum value is
-9,223,372,036,854,775,808.(-2^63)
• Maximum value is 9,223,372,036,854,775,807.(-2^63-1)
• This type is used when a wider range than int is needed.
• Default value is 0L.
• Example : long a= 100000L, long b= -200000L
float
• float data type is single-precision 32-bit IEEE 754 floating point.
• Float is mainly used to save memory in large arrays of floating point
numbers.
• Default value is 0.0f.
• Float data type is never used for precise values such as currency.
• Example: float f1=324.5f
Double
• Double data type is a double-precision 64-bit IEEE 754 floating point.
• This data type is generally used as the default data type for decimal
values. Generally the default choice.
• Double data type should never be used for precise values such as
currency.
• Default value is 0.0d.
• Example : double d1= 234.5
boolean
• Boolean data type represents one bit of information.
• There are only two possible values: true and false.
• This data type is used for simple flags that track true/false conditions.
• Default value is false.
• Example: boolean one=true
char
• char data type is a single 16-bit Unicode character.
• Minimum value is ‘u0000’or (0).
• Maximum value is ‘uffff’ (or 65,535).
• Char data type is used to store any character.
• Example: char letter=‘A’
Reference data types
• Reference variable are created using defined constructors of the classes.
They are used to access objects. These variables are declared to be
specific type that cannot be changed. For example employee.
• Class objects, and various type of array variables come under reference
data type.
• Default value of any reference variable is null.
• A reference variable can be used to refer to any object of declared type
or any compatible type.
• Example Animal animal = new Animal (“Dog”)
Java-Arrays
• Java provides a data structure, the array, which stores a fixed-size
sequential collection of elements of the same type. An array is used to
store a collection of data, but it is often more useful to think of an array as
a collection of variable of the same type.
• Instead of declaring individual variables, such as number0,number1, ….,
and number99, you declare one array variable such as numbers and use
numbers[0], numbers[1], and ….,numbers[99] to represent individual
variables.
Declaring array variables
• To use an array in a program, you must declare a variable to reference
the array, and you must specify the type of array the variable can
reference. Here is the syntax for declaring an array variable:
• dataType[] arrayRefVar;
Example
• double mylist[];
• Double[] mylist= new double[10];
Java session3

More Related Content

What's hot

Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm Madishetty Prathibha
 
java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part iijyoti_lakhani
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaJaved Rashid
 
Java basic data types
Java basic data typesJava basic data types
Java basic data types3trg
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netSireesh K
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Typesk v
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variablesteach4uin
 
Learning core java
Learning core javaLearning core java
Learning core javaAbhay Bharti
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Raj Naik
 

What's hot (20)

Java data types, variables and jvm
Java data types, variables and jvm Java data types, variables and jvm
Java data types, variables and jvm
 
Java Datatypes
Java DatatypesJava Datatypes
Java Datatypes
 
java programming basics - part ii
 java programming basics - part ii java programming basics - part ii
java programming basics - part ii
 
Java fundamentals
Java fundamentalsJava fundamentals
Java fundamentals
 
PCSTt11 overview of java
PCSTt11 overview of javaPCSTt11 overview of java
PCSTt11 overview of java
 
Data types in C
Data types in CData types in C
Data types in C
 
Data type
Data typeData type
Data type
 
Computer programming 2 Lesson 5
Computer programming 2  Lesson 5Computer programming 2  Lesson 5
Computer programming 2 Lesson 5
 
Data types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in javaData types, Variables, Expressions & Arithmetic Operators in java
Data types, Variables, Expressions & Arithmetic Operators in java
 
Java basic data types
Java basic data typesJava basic data types
Java basic data types
 
DATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.netDATATYPE IN C# CSHARP.net
DATATYPE IN C# CSHARP.net
 
Concept Of C++ Data Types
Concept Of C++ Data TypesConcept Of C++ Data Types
Concept Of C++ Data Types
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 
Data types in c++
Data types in c++Data types in c++
Data types in c++
 
Java data types
Java data typesJava data types
Java data types
 
Data Types
Data TypesData Types
Data Types
 
Arrays
ArraysArrays
Arrays
 
Learning core java
Learning core javaLearning core java
Learning core java
 
Data types in java
Data types in javaData types in java
Data types in java
 
Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive Data Types - Premetive and Non Premetive
Data Types - Premetive and Non Premetive
 

Similar to Java session3

Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2Berk Soysal
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptxSmitNikumbh
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART IHari Christian
 
CSC111-Chap_02.pdf
CSC111-Chap_02.pdfCSC111-Chap_02.pdf
CSC111-Chap_02.pdf2b75fd3051
 
Java platform
Java platformJava platform
Java platformVisithan
 
java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming NeedsRaja Sekhar
 
Literals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiersLiterals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiersTanishq Soni
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfYRABHI
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programmingHarshita Yadav
 
Java SpringMVC SpringBOOT (Divergent).ppt
Java SpringMVC SpringBOOT (Divergent).pptJava SpringMVC SpringBOOT (Divergent).ppt
Java SpringMVC SpringBOOT (Divergent).pptAayush Chimaniya
 
332 ch07
332 ch07332 ch07
332 ch07YaQ10
 
5variables in c#
5variables in c#5variables in c#
5variables in c#Sireesh K
 
introduction to python
 introduction to python introduction to python
introduction to pythonJincy Nelson
 
Learn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITLearn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITASIT
 

Similar to Java session3 (20)

Java - Basic Datatypes.pptx
Java - Basic Datatypes.pptxJava - Basic Datatypes.pptx
Java - Basic Datatypes.pptx
 
Java Tutorial Lab 2
Java Tutorial Lab 2Java Tutorial Lab 2
Java Tutorial Lab 2
 
Variable
VariableVariable
Variable
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
 
01 Java Language And OOP PART I
01 Java Language And OOP PART I01 Java Language And OOP PART I
01 Java Language And OOP PART I
 
Lect5
Lect5Lect5
Lect5
 
CSC111-Chap_02.pdf
CSC111-Chap_02.pdfCSC111-Chap_02.pdf
CSC111-Chap_02.pdf
 
Java platform
Java platformJava platform
Java platform
 
java Basic Programming Needs
java Basic Programming Needsjava Basic Programming Needs
java Basic Programming Needs
 
Literals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiersLiterals, primitive datatypes, variables, expressions, identifiers
Literals, primitive datatypes, variables, expressions, identifiers
 
cassignmentii-170424105623.pdf
cassignmentii-170424105623.pdfcassignmentii-170424105623.pdf
cassignmentii-170424105623.pdf
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Java SpringMVC SpringBOOT (Divergent).ppt
Java SpringMVC SpringBOOT (Divergent).pptJava SpringMVC SpringBOOT (Divergent).ppt
Java SpringMVC SpringBOOT (Divergent).ppt
 
332 ch07
332 ch07332 ch07
332 ch07
 
5. variables & data types
5. variables & data types5. variables & data types
5. variables & data types
 
Python Data-Types
Python Data-TypesPython Data-Types
Python Data-Types
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
 
introduction to python
 introduction to python introduction to python
introduction to python
 
Learn C LANGUAGE at ASIT
Learn C LANGUAGE at ASITLearn C LANGUAGE at ASIT
Learn C LANGUAGE at ASIT
 
Apex code (Salesforce)
Apex code (Salesforce)Apex code (Salesforce)
Apex code (Salesforce)
 

More from Jigarthacker

More from Jigarthacker (13)

File mangement
File mangementFile mangement
File mangement
 
Java session14
Java session14Java session14
Java session14
 
Java session13
Java session13Java session13
Java session13
 
Java session5
Java session5Java session5
Java session5
 
Java session4
Java session4Java session4
Java session4
 
Java session2
Java session2Java session2
Java session2
 
Computer networks
Computer networksComputer networks
Computer networks
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unit 1(sem-iv)
Unit 1(sem-iv)Unit 1(sem-iv)
Unit 1(sem-iv)
 
Unit 2
Unit 2Unit 2
Unit 2
 
Unit 1
Unit 1Unit 1
Unit 1
 
C programming
C programmingC programming
C programming
 
Basic object oriented approach
Basic object oriented approachBasic object oriented approach
Basic object oriented approach
 

Recently uploaded

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girlsssuser7cb4ff
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZTE
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2RajaP95
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfAsst.prof M.Gokilavani
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escortsranjana rawat
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidNikhilNagaraju
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AIabhishek36461
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxbritheesh05
 

Recently uploaded (20)

(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
Call Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call GirlsCall Girls Narol 7397865700 Independent Call Girls
Call Girls Narol 7397865700 Independent Call Girls
 
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
ZXCTN 5804 / ZTE PTN / ZTE POTN / ZTE 5804 PTN / ZTE POTN 5804 ( 100/200 GE Z...
 
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2HARMONY IN THE HUMAN BEING - Unit-II UHV-2
HARMONY IN THE HUMAN BEING - Unit-II UHV-2
 
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdfCCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
CCS355 Neural Network & Deep Learning UNIT III notes and Question bank .pdf
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
(MEERA) Dapodi Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Escorts
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
main PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfidmain PPT.pptx of girls hostel security using rfid
main PPT.pptx of girls hostel security using rfid
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Past, Present and Future of Generative AI
Past, Present and Future of Generative AIPast, Present and Future of Generative AI
Past, Present and Future of Generative AI
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Artificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptxArtificial-Intelligence-in-Electronics (K).pptx
Artificial-Intelligence-in-Electronics (K).pptx
 

Java session3

  • 3. JAVA Tokens • A java program is basically a collection of classes. • A class defined by a set of declaration statement and methods containing executable statements. • Most statements contain expression, which describe the actions carried out on data. • Smallest individual units in program are known as tokens. • The compiler recognizes them for building up expression and statements. • In simple terms, a java program is a collection of tokens, comments and white spaces. • Java language includes five types of tokens, they are – Reserved Keywords – Identifiers – Literals – Operators – Separators
  • 4. Keywords • Keywords are essential part of a language definition. They implement specific features of the language. Java language has reserved 50 words as keywords.
  • 5.
  • 6. Identifiers • Identifiers are programmer-designed tokens. They are used for naming classes, methods, variables, objects, labels, packages and interfaces in a program. Java identifiers follow the following rules: • Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. – They can have alphabets, digits, and the underscore and dollar sign characters. – They must not begin with a digit. – Uppercase and lowercase letters are distinct. – They can be of any length.
  • 7. Data type supported by JAVA • There are two type of data types available in JAVA – Primitive Data types – Reference/Object Data types
  • 8. Primitive Data Types • byte • short • int • long • float • double • boolean • char
  • 9. byte • Byte data type is a 8-bit signed two’s compliment integer. • Minimum value is -128 (-2^7) • Default value is 0 • Byte data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int. • Example: byte a = 100, byte b = -50
  • 10. Short • Short data type is a 16 bit signed two’s complement integer. • Minimum value is -32,768(-2^15) • Maximum value is 32,767 (2^15-1) • Short data type can also used to save memory as byte data type. A short is 2 times smaller than an int. • Default value is 0. • Example: short s=10000, short r=-20000
  • 11. int • int data type is a 32-bit signed two’s complement integer. • Minimum value is -2,147,483,648.(-2^31) • Maximum value is 2,147,483,647.(2^31-1) • int is generally used as the default data type for integral values unless there is a concern about memory. • The default value is 0. • Example: int a = 100000, int b = -200000
  • 12. long • long data type is 64-bit signed two’s complement integer. • Minimum value is -9,223,372,036,854,775,808.(-2^63) • Maximum value is 9,223,372,036,854,775,807.(-2^63-1) • This type is used when a wider range than int is needed. • Default value is 0L. • Example : long a= 100000L, long b= -200000L
  • 13. float • float data type is single-precision 32-bit IEEE 754 floating point. • Float is mainly used to save memory in large arrays of floating point numbers. • Default value is 0.0f. • Float data type is never used for precise values such as currency. • Example: float f1=324.5f
  • 14. Double • Double data type is a double-precision 64-bit IEEE 754 floating point. • This data type is generally used as the default data type for decimal values. Generally the default choice. • Double data type should never be used for precise values such as currency. • Default value is 0.0d. • Example : double d1= 234.5
  • 15. boolean • Boolean data type represents one bit of information. • There are only two possible values: true and false. • This data type is used for simple flags that track true/false conditions. • Default value is false. • Example: boolean one=true
  • 16. char • char data type is a single 16-bit Unicode character. • Minimum value is ‘u0000’or (0). • Maximum value is ‘uffff’ (or 65,535). • Char data type is used to store any character. • Example: char letter=‘A’
  • 17. Reference data types • Reference variable are created using defined constructors of the classes. They are used to access objects. These variables are declared to be specific type that cannot be changed. For example employee. • Class objects, and various type of array variables come under reference data type. • Default value of any reference variable is null. • A reference variable can be used to refer to any object of declared type or any compatible type. • Example Animal animal = new Animal (“Dog”)
  • 18. Java-Arrays • Java provides a data structure, the array, which stores a fixed-size sequential collection of elements of the same type. An array is used to store a collection of data, but it is often more useful to think of an array as a collection of variable of the same type. • Instead of declaring individual variables, such as number0,number1, …., and number99, you declare one array variable such as numbers and use numbers[0], numbers[1], and ….,numbers[99] to represent individual variables.
  • 19. Declaring array variables • To use an array in a program, you must declare a variable to reference the array, and you must specify the type of array the variable can reference. Here is the syntax for declaring an array variable: • dataType[] arrayRefVar;
  • 20. Example • double mylist[]; • Double[] mylist= new double[10];