SlideShare a Scribd company logo
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.
Java session3
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 (20)

PDF
Java data types, variables and jvm
Madishetty Prathibha
 
PPTX
Java Datatypes
Mayank Aggarwal
 
PPTX
java programming basics - part ii
jyoti_lakhani
 
PPTX
Java fundamentals
Jayfee Ramos
 
PPTX
PCSTt11 overview of java
Archana Gopinath
 
PPTX
Data types in C
Satveer Mann
 
PPSX
Data type
Frijo Francis
 
PPTX
Computer programming 2 Lesson 5
MLG College of Learning, Inc
 
PPSX
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 
PDF
Java basic data types
3trg
 
PPTX
DATATYPE IN C# CSHARP.net
Sireesh K
 
PPTX
Concept Of C++ Data Types
k v
 
PPTX
L2 datatypes and variables
teach4uin
 
PPTX
Data types in c++
Venkata.Manish Reddy
 
PPTX
Java data types
AbhishekMondal42
 
PPTX
Data Types
Vivek Srivastava
 
PPTX
Arrays
Mubashar Iqbal
 
PPTX
Learning core java
Abhay Bharti
 
PPTX
Data types in java
HarshitaAshwani
 
PPTX
Data Types - Premetive and Non Premetive
Raj Naik
 
Java data types, variables and jvm
Madishetty Prathibha
 
Java Datatypes
Mayank Aggarwal
 
java programming basics - part ii
jyoti_lakhani
 
Java fundamentals
Jayfee Ramos
 
PCSTt11 overview of java
Archana Gopinath
 
Data types in C
Satveer Mann
 
Data type
Frijo Francis
 
Computer programming 2 Lesson 5
MLG College of Learning, Inc
 
Data types, Variables, Expressions & Arithmetic Operators in java
Javed Rashid
 
Java basic data types
3trg
 
DATATYPE IN C# CSHARP.net
Sireesh K
 
Concept Of C++ Data Types
k v
 
L2 datatypes and variables
teach4uin
 
Data types in c++
Venkata.Manish Reddy
 
Java data types
AbhishekMondal42
 
Data Types
Vivek Srivastava
 
Learning core java
Abhay Bharti
 
Data types in java
HarshitaAshwani
 
Data Types - Premetive and Non Premetive
Raj Naik
 

Similar to Java session3 (20)

PPTX
Java - Basic Datatypes.pptx
Nagaraju Pamarthi
 
PPTX
Java Tutorial Lab 2
Berk Soysal
 
PPTX
intro_java (1).pptx
SmitNikumbh
 
PPTX
01 Java Language And OOP PART I
Hari Christian
 
PPTX
Introduction to java Programming Language
rubyjeyamani1
 
PPTX
Lect5
Jamsher bhanbhro
 
PDF
CSC111-Chap_02.pdf
2b75fd3051
 
PPTX
Java platform
Visithan
 
PPTX
java Basic Programming Needs
Raja Sekhar
 
PPTX
Object oriented programming1 Week 1.pptx
MirHazarKhan1
 
PPTX
Literals, primitive datatypes, variables, expressions, identifiers
Tanishq Soni
 
PPTX
data types in C programming
Harshita Yadav
 
PDF
cassignmentii-170424105623.pdf
YRABHI
 
PPT
Java SpringMVC SpringBOOT (Divergent).ppt
Aayush Chimaniya
 
PDF
332 ch07
YaQ10
 
PPTX
5. variables & data types
M H Buddhika Ariyaratne
 
PPTX
Python Data-Types
Akhil Kaushik
 
PPTX
Introduction to Java Basics Programming Java Basics-I.pptx
SANDHYAP32
 
PPTX
5variables in c#
Sireesh K
 
Java - Basic Datatypes.pptx
Nagaraju Pamarthi
 
Java Tutorial Lab 2
Berk Soysal
 
intro_java (1).pptx
SmitNikumbh
 
01 Java Language And OOP PART I
Hari Christian
 
Introduction to java Programming Language
rubyjeyamani1
 
CSC111-Chap_02.pdf
2b75fd3051
 
Java platform
Visithan
 
java Basic Programming Needs
Raja Sekhar
 
Object oriented programming1 Week 1.pptx
MirHazarKhan1
 
Literals, primitive datatypes, variables, expressions, identifiers
Tanishq Soni
 
data types in C programming
Harshita Yadav
 
cassignmentii-170424105623.pdf
YRABHI
 
Java SpringMVC SpringBOOT (Divergent).ppt
Aayush Chimaniya
 
332 ch07
YaQ10
 
5. variables & data types
M H Buddhika Ariyaratne
 
Python Data-Types
Akhil Kaushik
 
Introduction to Java Basics Programming Java Basics-I.pptx
SANDHYAP32
 
5variables in c#
Sireesh K
 
Ad

More from Jigarthacker (13)

PPSX
File mangement
Jigarthacker
 
PPTX
Java session14
Jigarthacker
 
PPTX
Java session13
Jigarthacker
 
PPSX
Java session5
Jigarthacker
 
PPSX
Java session4
Jigarthacker
 
PPTX
Java session2
Jigarthacker
 
PPSX
Computer networks
Jigarthacker
 
PPSX
Unit 2
Jigarthacker
 
PPSX
Unit 1(sem-iv)
Jigarthacker
 
PPSX
Unit 2
Jigarthacker
 
PPSX
Unit 1
Jigarthacker
 
PPTX
C programming
Jigarthacker
 
PDF
Basic object oriented approach
Jigarthacker
 
File mangement
Jigarthacker
 
Java session14
Jigarthacker
 
Java session13
Jigarthacker
 
Java session5
Jigarthacker
 
Java session4
Jigarthacker
 
Java session2
Jigarthacker
 
Computer networks
Jigarthacker
 
Unit 2
Jigarthacker
 
Unit 1(sem-iv)
Jigarthacker
 
Unit 2
Jigarthacker
 
Unit 1
Jigarthacker
 
C programming
Jigarthacker
 
Basic object oriented approach
Jigarthacker
 
Ad

Recently uploaded (20)

PDF
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PPTX
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
PDF
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
PPTX
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
PPTX
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
PPT
Testing and final inspection of a solar PV system
MuhammadSanni2
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PDF
Design Thinking basics for Engineers.pdf
CMR University
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PDF
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
PDF
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
PPTX
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
MODULE-5 notes [BCG402-CG&V] PART-B.pdf
Alvas Institute of Engineering and technology, Moodabidri
 
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Reasons for the succes of MENARD PRESSUREMETER.pdf
majdiamz
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
fatigue in aircraft structures-221113192308-0ad6dc8c.pptx
aviatecofficial
 
WD2(I)-RFQ-GW-1415_ Shifting and Filling of Sand in the Pond at the WD5 Area_...
ShahadathHossain23
 
OCS353 DATA SCIENCE FUNDAMENTALS- Unit 1 Introduction to Data Science
A R SIVANESH M.E., (Ph.D)
 
Lecture 1 Shell and Tube Heat exchanger-1.pptx
mailforillegalwork
 
Testing and final inspection of a solar PV system
MuhammadSanni2
 
Distribution reservoir and service storage pptx
dhanashree78
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
Design Thinking basics for Engineers.pdf
CMR University
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Submit Your Papers-International Journal on Cybernetics & Informatics ( IJCI)
IJCI JOURNAL
 
aAn_Introduction_to_Arcadia_20150115.pdf
henriqueltorres1
 
MODULE 04 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 

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.
  • 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];