SlideShare a Scribd company logo
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Core Java Programming
Data-types and Variables
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
•JVM
• JVM (Java Virtual Machine) is a software. It is a
specification that provides runtime environment in
which java byte code can be executed. It is not physically
exists.
• JVMs are not same for all hardware and software, for
example for window os JVM is different and for Linux
JVM is different. JVM, JRE and JDK are platform
dependent because configuration of each OS differs.
But, Java is platform independent.
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
•JRE
• JRE is an acronym for Java Runtime Environment. It is
used to provide runtime environment. It is the
implementation of JVM.
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
•JDK
• The Java Development Kit (JDK) is the primary
componens. It physically exists. It is collection of
programming tools and JRE, JVM.
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Keywords in Java...
• There are 49 reserved keywords currently defined
in the Java language. These keywords, combined
with the syntax of the operators and separators,
form the definition of the Java language. These
keywords cannot be used as names for a variable,
Class, or method.
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Data Types in Java...
• In Java , there are really two different
categories in which data types have been divided :
– 1. Primitive Types
– 2. Reference Types
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Data Types in Java...
Reser.Word Data Type Size
byte Byte length integer 1 byte
Short Short Integer 2 bytes
int Integer 4 bytes
long Long Integers 8 bytes
float Single precision number 4 bytes
double Double Precision number 8 bytes
char Character (16 bit Unicode) 2 bytes
boolean Has value true or false A Boolean Value
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Range of Data Types…
Data Type Range
byte -128 to 127
short -32768 to 32767
int -2,147,483,648 to 2,147,483,647
long -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807
float 3.4e-038 to 3.4e+038
double 1.7e-308 to 1.7 e+308
char 0 to 65535
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Identifiers in Java...
• Identifiers are the names of variables , methods ,
classes , packages and interfaces. Identifiers must
be composed of letters , numbers , the underscore
and the dollar sign.$.
• They cannot contain white spaces, Identifiers may
only begin with a letter, the underscore or a dollar
sign. You cannot begin a variable name with a
number. All variable are case sensitive for example
• MyVariable is not same as myVariable
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Invalid Variable Names...
• My Variable // contains a space
• 9pins // Begins with a digit
• a+b // the plus sign is not an alphanumeric
character
• testing 1-2-3
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Integer Variables...
• The following lines show how to create variables
of integer types :
• long My_First_Byte = 10;
• int a=20;
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Boolean Variables...
• A Boolean Variable is not a number. It can have
one of two values true or False. There are two
ways to set its values .
• The first way to do this is explicitly.
• Ex :a) boolean firstboolean = false;
• b) boolean firstboolean = secondboolean;
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Float & Double Variables...
• In Java, floating point numbers are represented by
the types float and double . Both of these follow a
standard floating point specification.
• float a = 35.6f; double x = 356556.25;
• float b = 35.7F; double y = 356556.25;
• a,b,x,y are variables.
• Note : 35.6f and 35.7F are single Precision Literals.
As Floating point numbers are treated as double
precision quantities. To force them to single
precision we use f and F.
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Literals...
• Literals are pieces of Java source code that indicates
explicit values. Literals in Java refer to fixed values
that do not change during the execution of a program.
Java supports several types of constants.
A) Integer Constants
B) Real Constants
C) Single Character Constants
D) String Constants
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
String Literals...
• The String Literal is always enclosed in double
quotes . Java uses a String class to implement
Strings whereas C and C++ use an array of
characters.
• For example :
• String poem = “Java supports Multithreading”;
PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR
Boolean Literals...
• Boolean Literal can have either of the values : true
or false.
• They do not correspond to the numeric value 1 and
0 as in C and C++.
Ad

More Related Content

Similar to Lecture2_Datatypes_Variables.ppt (20)

Java Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece departmentJava Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece department
om2348023vats
 
Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)
Nuzhat Memon
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
Ahmad sohail Kakar
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
Edureka!
 
Java
Java Java
Java
Edureka!
 
Java introduction
Java introductionJava introduction
Java introduction
GaneshKumarKanthiah
 
Learning core java
Learning core javaLearning core java
Learning core java
Abhay Bharti
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
Introduction to Java Basics Programming Java Basics-I.pptx
Introduction to Java Basics Programming Java Basics-I.pptxIntroduction to Java Basics Programming Java Basics-I.pptx
Introduction to Java Basics Programming Java Basics-I.pptx
SANDHYAP32
 
JAVA in Artificial intelligent
JAVA in Artificial intelligentJAVA in Artificial intelligent
JAVA in Artificial intelligent
Virat Andodariya
 
java in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariyajava in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariya
viratandodariya
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
chnrketan
 
Pi j1.2 variable-assignment
Pi j1.2 variable-assignmentPi j1.2 variable-assignment
Pi j1.2 variable-assignment
mcollison
 
Full CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languageFull CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java language
ssuser2963071
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
SmitNikumbh
 
Complete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itComplete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept it
lokeshpappaka10
 
Java script
Java scriptJava script
Java script
Prarthan P
 
PPT Lecture-1.2 java basics jvm, literals,
PPT Lecture-1.2 java basics jvm, literals,PPT Lecture-1.2 java basics jvm, literals,
PPT Lecture-1.2 java basics jvm, literals,
shubhamkumar248717
 
javaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
javaeanjjisjejrehurfhjhjfeauojksfjdi.pptjavaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
javaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
eraqhuzay69
 
Lec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented ProgrammingLec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented Programming
Badar Waseer
 
Java Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece departmentJava Basics.pptx from nit patna ece department
Java Basics.pptx from nit patna ece department
om2348023vats
 
Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)Std 12 Computer Chapter 7 Java Basics (Part 1)
Std 12 Computer Chapter 7 Java Basics (Part 1)
Nuzhat Memon
 
Android webinar class_java_review
Android webinar class_java_reviewAndroid webinar class_java_review
Android webinar class_java_review
Edureka!
 
Learning core java
Learning core javaLearning core java
Learning core java
Abhay Bharti
 
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
AssignmentjsnsnshshusjdnsnshhzudjdndndjdAssignmentjsnsnshshusjdnsnshhzudjdndndjd
Assignmentjsnsnshshusjdnsnshhzudjdndndjd
tusharjain613841
 
Introduction to Java Basics Programming Java Basics-I.pptx
Introduction to Java Basics Programming Java Basics-I.pptxIntroduction to Java Basics Programming Java Basics-I.pptx
Introduction to Java Basics Programming Java Basics-I.pptx
SANDHYAP32
 
JAVA in Artificial intelligent
JAVA in Artificial intelligentJAVA in Artificial intelligent
JAVA in Artificial intelligent
Virat Andodariya
 
java in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariyajava in Aartificial intelligent by virat andodariya
java in Aartificial intelligent by virat andodariya
viratandodariya
 
Java programing language unit 1 introduction
Java programing language unit 1 introductionJava programing language unit 1 introduction
Java programing language unit 1 introduction
chnrketan
 
Pi j1.2 variable-assignment
Pi j1.2 variable-assignmentPi j1.2 variable-assignment
Pi j1.2 variable-assignment
mcollison
 
Full CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java languageFull CSE 310 Unit 1 PPT.pptx for java language
Full CSE 310 Unit 1 PPT.pptx for java language
ssuser2963071
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
SmitNikumbh
 
Complete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itComplete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept it
lokeshpappaka10
 
PPT Lecture-1.2 java basics jvm, literals,
PPT Lecture-1.2 java basics jvm, literals,PPT Lecture-1.2 java basics jvm, literals,
PPT Lecture-1.2 java basics jvm, literals,
shubhamkumar248717
 
javaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
javaeanjjisjejrehurfhjhjfeauojksfjdi.pptjavaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
javaeanjjisjejrehurfhjhjfeauojksfjdi.ppt
eraqhuzay69
 
Lec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented ProgrammingLec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented Programming
Badar Waseer
 

Recently uploaded (20)

Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
Data Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptxData Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptx
RushaliDeshmukh2
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
Artificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptxArtificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptx
DrMarwaElsherif
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Journal of Soft Computing in Civil Engineering
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
New Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdfNew Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdf
mohamedezzat18803
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
Degree_of_Automation.pdf for Instrumentation and industrial specialist
Degree_of_Automation.pdf for  Instrumentation  and industrial specialistDegree_of_Automation.pdf for  Instrumentation  and industrial specialist
Degree_of_Automation.pdf for Instrumentation and industrial specialist
shreyabhosale19
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Smart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineeringSmart Storage Solutions.pptx for production engineering
Smart Storage Solutions.pptx for production engineering
rushikeshnavghare94
 
new ppt artificial intelligence historyyy
new ppt artificial intelligence historyyynew ppt artificial intelligence historyyy
new ppt artificial intelligence historyyy
PianoPianist
 
Raish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdfRaish Khanji GTU 8th sem Internship Report.pdf
Raish Khanji GTU 8th sem Internship Report.pdf
RaishKhanji
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
Data Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptxData Structures_Linear data structures Linked Lists.pptx
Data Structures_Linear data structures Linked Lists.pptx
RushaliDeshmukh2
 
15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...15th International Conference on Computer Science, Engineering and Applicatio...
15th International Conference on Computer Science, Engineering and Applicatio...
IJCSES Journal
 
Artificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptxArtificial Intelligence introduction.pptx
Artificial Intelligence introduction.pptx
DrMarwaElsherif
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Compiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptxCompiler Design Unit1 PPT Phases of Compiler.pptx
Compiler Design Unit1 PPT Phases of Compiler.pptx
RushaliDeshmukh2
 
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdfRICS Membership-(The Royal Institution of Chartered Surveyors).pdf
RICS Membership-(The Royal Institution of Chartered Surveyors).pdf
MohamedAbdelkader115
 
Machine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptxMachine learning project on employee attrition detection using (2).pptx
Machine learning project on employee attrition detection using (2).pptx
rajeswari89780
 
New Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdfNew Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdf
mohamedezzat18803
 
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdffive-year-soluhhhhhhhhhhhhhhhhhtions.pdf
five-year-soluhhhhhhhhhhhhhhhhhtions.pdf
AdityaSharma944496
 
Ad

Lecture2_Datatypes_Variables.ppt

  • 1. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Core Java Programming Data-types and Variables
  • 2. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR •JVM • JVM (Java Virtual Machine) is a software. It is a specification that provides runtime environment in which java byte code can be executed. It is not physically exists. • JVMs are not same for all hardware and software, for example for window os JVM is different and for Linux JVM is different. JVM, JRE and JDK are platform dependent because configuration of each OS differs. But, Java is platform independent.
  • 3. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR •JRE • JRE is an acronym for Java Runtime Environment. It is used to provide runtime environment. It is the implementation of JVM.
  • 4. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR •JDK • The Java Development Kit (JDK) is the primary componens. It physically exists. It is collection of programming tools and JRE, JVM.
  • 5. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Keywords in Java... • There are 49 reserved keywords currently defined in the Java language. These keywords, combined with the syntax of the operators and separators, form the definition of the Java language. These keywords cannot be used as names for a variable, Class, or method.
  • 6. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Data Types in Java... • In Java , there are really two different categories in which data types have been divided : – 1. Primitive Types – 2. Reference Types
  • 7. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Data Types in Java... Reser.Word Data Type Size byte Byte length integer 1 byte Short Short Integer 2 bytes int Integer 4 bytes long Long Integers 8 bytes float Single precision number 4 bytes double Double Precision number 8 bytes char Character (16 bit Unicode) 2 bytes boolean Has value true or false A Boolean Value
  • 8. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Range of Data Types… Data Type Range byte -128 to 127 short -32768 to 32767 int -2,147,483,648 to 2,147,483,647 long -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 float 3.4e-038 to 3.4e+038 double 1.7e-308 to 1.7 e+308 char 0 to 65535
  • 9. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Identifiers in Java... • Identifiers are the names of variables , methods , classes , packages and interfaces. Identifiers must be composed of letters , numbers , the underscore and the dollar sign.$. • They cannot contain white spaces, Identifiers may only begin with a letter, the underscore or a dollar sign. You cannot begin a variable name with a number. All variable are case sensitive for example • MyVariable is not same as myVariable
  • 10. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Invalid Variable Names... • My Variable // contains a space • 9pins // Begins with a digit • a+b // the plus sign is not an alphanumeric character • testing 1-2-3
  • 11. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Integer Variables... • The following lines show how to create variables of integer types : • long My_First_Byte = 10; • int a=20;
  • 12. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Boolean Variables... • A Boolean Variable is not a number. It can have one of two values true or False. There are two ways to set its values . • The first way to do this is explicitly. • Ex :a) boolean firstboolean = false; • b) boolean firstboolean = secondboolean;
  • 13. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Float & Double Variables... • In Java, floating point numbers are represented by the types float and double . Both of these follow a standard floating point specification. • float a = 35.6f; double x = 356556.25; • float b = 35.7F; double y = 356556.25; • a,b,x,y are variables. • Note : 35.6f and 35.7F are single Precision Literals. As Floating point numbers are treated as double precision quantities. To force them to single precision we use f and F.
  • 14. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Literals... • Literals are pieces of Java source code that indicates explicit values. Literals in Java refer to fixed values that do not change during the execution of a program. Java supports several types of constants. A) Integer Constants B) Real Constants C) Single Character Constants D) String Constants
  • 15. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR String Literals... • The String Literal is always enclosed in double quotes . Java uses a String class to implement Strings whereas C and C++ use an array of characters. • For example : • String poem = “Java supports Multithreading”;
  • 16. PRANVEER SINGH INSTITUTE OF TECHNOLOGY, KANPUR Boolean Literals... • Boolean Literal can have either of the values : true or false. • They do not correspond to the numeric value 1 and 0 as in C and C++.