SlideShare uma empresa Scribd logo
1 de 12
Java Tutorial
Data Types and Variables
Content
• What is Data Type in Java
• What is Variable
What is Data Type in Java
• Data type specifies the size and type of values that can be stored in
an identifier.
• Data types in Java are classified into two types:
• Primitive
• Non-primitive
Primitive Data Types
• Integer
• Character
• Boolean
• Floating Point
Non-primitive
• Classes
• Interfaces
• Arrays
Integer
• Integer types can hold whole numbers such as 123 and −96. The size
of the values that can be stored depends on the integer type that
we choose.
• Byte
• Short
• Int
• long
Floating Point
• Floating point data types are used to represent numbers with a
fractional part
• float
• double
Character
• It stores character constants in the memory.
• char
Boolean
• Boolean data types are used to store values with two states:
• true
• false.
What is Variable
• A Java variable is a piece of memory that can contain a data value
• There are different types of variables in Java. They are as follows:
• Instance Variables (Non-Static Fields)
• Class Variables (Static Fields)
• Local Variables
• Parameters
Variable Declaration
• Syntax for variable declaration
datatype1 variable1, datatype2 variable2, … datatypen variablen;
• For Example
• int a; char ch;
•Initialization
• a = 10;
• ch = ‘A’;
Java Data Types and Variables

Mais conteúdo relacionado

Mais procurados

Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
Ravi_Kant_Sahu
 

Mais procurados (20)

Data types
Data typesData types
Data types
 
Basics of JAVA programming
Basics of JAVA programmingBasics of JAVA programming
Basics of JAVA programming
 
Arrays in Java
Arrays in JavaArrays in Java
Arrays in Java
 
Java input
Java inputJava input
Java input
 
Type casting in java
Type casting in javaType casting in java
Type casting in java
 
Java Tokens
Java  TokensJava  Tokens
Java Tokens
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Finalize() method
Finalize() methodFinalize() method
Finalize() method
 
Object-oriented concepts
Object-oriented conceptsObject-oriented concepts
Object-oriented concepts
 
Java if else condition - powerpoint persentation
Java if else condition - powerpoint persentationJava if else condition - powerpoint persentation
Java if else condition - powerpoint persentation
 
Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
 
Wrapper classes
Wrapper classes Wrapper classes
Wrapper classes
 
Features of java
Features of javaFeatures of java
Features of java
 
java Features
java Featuresjava Features
java Features
 
ITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in javaITFT-Constants, variables and data types in java
ITFT-Constants, variables and data types in java
 
Applets
AppletsApplets
Applets
 
6. static keyword
6. static keyword6. static keyword
6. static keyword
 
Data types
Data typesData types
Data types
 
Java conditional statements
Java conditional statementsJava conditional statements
Java conditional statements
 

Semelhante a Java Data Types and Variables

demo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.pptdemo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.ppt
FerdieBalang
 
C Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptxC Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptx
Murali M
 
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptxOOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
AhmedMehmood35
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
Ravi_Kant_Sahu
 

Semelhante a Java Data Types and Variables (20)

Data types IN JAVA
Data types IN JAVAData types IN JAVA
Data types IN JAVA
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 
Variable
VariableVariable
Variable
 
Csc240 -lecture_4
Csc240  -lecture_4Csc240  -lecture_4
Csc240 -lecture_4
 
Lec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented ProgrammingLec 1.3 Object Oriented Programming
Lec 1.3 Object Oriented Programming
 
demo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.pptdemo1 java of demo 1 java with demo 1 java.ppt
demo1 java of demo 1 java with demo 1 java.ppt
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 
C Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptxC Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptx
 
Learning core java
Learning core javaLearning core java
Learning core java
 
Java session3
Java session3Java session3
Java session3
 
5variables in c#
5variables in c#5variables in c#
5variables in c#
 
Data Types in C language
Data Types in C languageData Types in C language
Data Types in C language
 
Data type
Data typeData type
Data type
 
COMPUTER PROGRAMMING LANGUAGE.pptx
COMPUTER PROGRAMMING LANGUAGE.pptxCOMPUTER PROGRAMMING LANGUAGE.pptx
COMPUTER PROGRAMMING LANGUAGE.pptx
 
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptxOOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
OOP - Lecture04 - Variables, DataTypes and TypeConversion.pptx
 
CS4443 - Modern Programming Language - I Lecture (2)
CS4443 - Modern Programming Language - I  Lecture (2)CS4443 - Modern Programming Language - I  Lecture (2)
CS4443 - Modern Programming Language - I Lecture (2)
 
intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
 
Java basic datatypes
Java basic datatypesJava basic datatypes
Java basic datatypes
 
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
 
L2 datatypes and variables
L2 datatypes and variablesL2 datatypes and variables
L2 datatypes and variables
 

Último

Último (20)

Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 

Java Data Types and Variables

  • 1. Java Tutorial Data Types and Variables
  • 2. Content • What is Data Type in Java • What is Variable
  • 3. What is Data Type in Java • Data type specifies the size and type of values that can be stored in an identifier. • Data types in Java are classified into two types: • Primitive • Non-primitive
  • 4. Primitive Data Types • Integer • Character • Boolean • Floating Point
  • 6. Integer • Integer types can hold whole numbers such as 123 and −96. The size of the values that can be stored depends on the integer type that we choose. • Byte • Short • Int • long
  • 7. Floating Point • Floating point data types are used to represent numbers with a fractional part • float • double
  • 8. Character • It stores character constants in the memory. • char
  • 9. Boolean • Boolean data types are used to store values with two states: • true • false.
  • 10. What is Variable • A Java variable is a piece of memory that can contain a data value • There are different types of variables in Java. They are as follows: • Instance Variables (Non-Static Fields) • Class Variables (Static Fields) • Local Variables • Parameters
  • 11. Variable Declaration • Syntax for variable declaration datatype1 variable1, datatype2 variable2, … datatypen variablen; • For Example • int a; char ch; •Initialization • a = 10; • ch = ‘A’;