SlideShare ist ein Scribd-Unternehmen logo
1 von 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

Weitere ähnliche Inhalte

Was ist angesagt?

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
 

Was ist angesagt? (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
 

Ähnlich wie 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
 

Ähnlich wie 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)
 

Mehr von Jigarthacker

Mehr von 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
 

Kürzlich hochgeladen

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingrknatarajan
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfKamal Acharya
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGSIVASHANKAR N
 
(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
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...ranjana rawat
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)simmis5
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdfKamal Acharya
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 

Kürzlich hochgeladen (20)

UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and workingUNIT-V FMM.HYDRAULIC TURBINE - Construction and working
UNIT-V FMM.HYDRAULIC TURBINE - Construction and working
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdfONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
ONLINE FOOD ORDER SYSTEM PROJECT REPORT.pdf
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTINGMANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
MANUFACTURING PROCESS-II UNIT-1 THEORY OF METAL CUTTING
 
(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...
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
The Most Attractive Pune Call Girls Manchar 8250192130 Will You Miss This Cha...
 
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur EscortsRussian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
Russian Call Girls in Nagpur Grishma Call 7001035870 Meet With Nagpur Escorts
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)Java Programming :Event Handling(Types of Events)
Java Programming :Event Handling(Types of Events)
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Online banking management system project.pdf
Online banking management system project.pdfOnline banking management system project.pdf
Online banking management system project.pdf
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 

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