SlideShare a Scribd company logo
DATA TYPES
SANJAI D
2313212027014
Data Types in Java
Data types specify the different sizes and values that can be stored in
the variable.
There are two types of data types in Java:
Primitive data types: The primitive data types include boolean,
char, byte, short, int, long, float and double.
Non-primitive data types: The non-primitive data types
include Classes, Interfaces, and Arrays.
Java Primitive Data Types
In Java language, primitive data
types are the building blocks of
data manipulation. These are the
most basic data types available
in java language.
There are 8 types of primitive data
types:
 boolean data type
 byte data type
 char data type
 short data type
 int data type
 long data type
 float data type
 double data type
DATA TYPES in Python done by Sanajai of MCA
DATA TYPES in Python done by Sanajai of MCA
Boolean Data Type
The Boolean data type is used to store only two possible values: true
and false. This data type is used for simple flags that track true/false
conditions.
Example:
Boolean one = false
Example - 1
public class Main
{
public static void main(String[] args)
{
int myAge = 25;
int votingAge = 18;
System.out.println(myAge >= votingAge);
// returns true (25 year olds are allowed to vote!)
}
}
Output:
true
Byte Data Type
The byte data type is an example of primitive data type. It is an 8-bit
signed two's complement integer. Its value-range lies between -128 to
127.
Its minimum value is -128 and maximum value is 127. Its default
value is 0.
Example:
byte a = 10, byte b = -20
Example - 1
public class Main
{
public static void main(String[] args)
{
byte myNum = 100;
System.out.println(myNum);
}
}
Output:
100
Short Data Type
The short data type is a 16-bit signed two's complement integer. Its
value-range lies between -32,768 to 32,767 .
Its minimum value is -32,768 and maximum value is 32,767. Its default
value is 0.
The short data type can also be used to save memory just like byte
data type. A short data type is 2 times smaller than an integer.
Example:
short s = 10000, short r = -5000
Example - 1
public class Main
{
public static void main(String[] args)
{
short myNum = 5000;
System.out.println(myNum);
}
}
Output:
5000
Int Data Type
The int data type is a 32-bit signed two's complement integer. Its
value-range lies between - 2,147,483,648 to 2,147,483,647.
Its minimum value is - 2,147,483,648 and maximum value is
2,147,483,647. Its default value is 0.
Example:
int a = 100000, int b = -200000
Example - 1
public class Main
{
public static void main(String[] args)
{
int myNum = 100000;
System.out.println(myNum);
}
}
Output:
100000
Long Data Type
The long data type is a 64-bit two's complement integer. Its value-
range lies between -9,223,372,036,854,775,808 to
9,223,372,036,854,775,807.
Its default value is 0. The long data type is used when you
need a range of values more than those provided by int.
Example:
long a = 100000L, long b = -200000L
Example - 1
public class Main
{
public static void main(String[] args)
{
long myNum = 15000000000L;
System.out.println(myNum);
}
}
Output:
15000000000
Float Data Type
The float data type is a single-precision 32-bit floating point. Its
value range is unlimited. It is recommended to use a float if you need to save
memory in large arrays of floating point numbers.
The float data type should never be used for precise values, such as
currency. Its default value is 0.0F.
Example:
float f1 = 234.5f
Example - 1
public class Main
{
public static void main(String[] args)
{
float myNum = 5.75f;
System.out.println(myNum);
}
}
Output:
5.75
Char Data Type
The char data type is a single 16-bit Unicode character. Its value-
range lies between 'u0000' (or 0) to 'uffff'.
The char data type is used to store characters.
Example:
char letterA = 'A'
Example - 1
public class Main
{
public static void main(String[] args)
{
char myGrade = 'B';
System.out.println(my Grade);
}
}
Output:
B
Double Data Type
The double data type is a double-precision 64-bit floating point. Its
value range is unlimited. The double data type is generally used for decimal
values just like float.
The double data type also should never be used for precise values,
such as currency. Its default value is 0.0d.
Example:
double d1 = 12.3
Example - 1
public class Main
{
public static void main(String[] args)
{
double myNum = 19.99d;
System.out.println(myNum);
}
}
Output:
19.99
THANK YOU

More Related Content

PPTX
a variable in Java must be a specified data type
PPTX
Computer programming 2 Lesson 5
PPTX
Computer Programming Java Data Types.pptx
PPTX
Java - Basic Datatypes.pptx
PPTX
5. variables & data types
PPTX
Data types
PPTX
Data types - brainsmartlabs
PPTX
Datatype introduction- JAVA
a variable in Java must be a specified data type
Computer programming 2 Lesson 5
Computer Programming Java Data Types.pptx
Java - Basic Datatypes.pptx
5. variables & data types
Data types
Data types - brainsmartlabs
Datatype introduction- JAVA

Similar to DATA TYPES in Python done by Sanajai of MCA (20)

PPTX
This is a python data types ppt it is used for bca student also
PPTX
JAVA LESSON-01.pptx
PPTX
Data types IN JAVA
PPTX
PPSX
Java session3
PDF
Java basic datatypes
PPTX
Java data types
PPTX
Topic-5_-Programming-Fundamentals-Part-2.pptx
PPTX
DATATYPES IN JAVA primitive and nonprimitive.pptx
PPTX
java programming basics - part ii
PPS
Data types ,variables,array
PPTX
Advanced java programming - DATA TYPES, VARIABLES, ARRAYS
PPTX
Java_Access_Specifiers_and_Data_Types.pptx
PPT
Data types
PDF
CIS 1403 Lab 2- Data Types and Variables
PDF
Java basic datatypes
PPTX
Java Data Types
PPTX
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
DOCX
data types in java will help to clear the base
This is a python data types ppt it is used for bca student also
JAVA LESSON-01.pptx
Data types IN JAVA
Java session3
Java basic datatypes
Java data types
Topic-5_-Programming-Fundamentals-Part-2.pptx
DATATYPES IN JAVA primitive and nonprimitive.pptx
java programming basics - part ii
Data types ,variables,array
Advanced java programming - DATA TYPES, VARIABLES, ARRAYS
Java_Access_Specifiers_and_Data_Types.pptx
Data types
CIS 1403 Lab 2- Data Types and Variables
Java basic datatypes
Java Data Types
Data types in java | What is Datatypes in Java | Learning with RD | Created b...
data types in java will help to clear the base
Ad

More from JPrince9 (11)

PPTX
Application-of-Beagle-Bone-Black-and-Electric-Imp-Smart-Farming-Solutions.pptx
PPTX
COSTS & SCALING UP SOFTWARE in IoT .pptx
PPTX
Pig-Latin-Overview-and-Primitive-Data-Types.pptx
PPTX
435819601-Advanced-Java_Study About Java.pptx
PPTX
Software Development Technologies SDT.PPTX
PPTX
High_Performance_ComputingforComputers.pptx
PPTX
API_Strategy_Architecture_Development.pptx
PPTX
Azure_Kubernetes_Services_(AKS)0111.pptx
PPTX
API_Gateways_&_API_Security-1(API Securities and Gateway).pptx
PPT
Digital Signature in CryptographyElgammal
PPT
Genetic_Algorithms(1,2,3,4,5)_ML_AI_DS.ppt
Application-of-Beagle-Bone-Black-and-Electric-Imp-Smart-Farming-Solutions.pptx
COSTS & SCALING UP SOFTWARE in IoT .pptx
Pig-Latin-Overview-and-Primitive-Data-Types.pptx
435819601-Advanced-Java_Study About Java.pptx
Software Development Technologies SDT.PPTX
High_Performance_ComputingforComputers.pptx
API_Strategy_Architecture_Development.pptx
Azure_Kubernetes_Services_(AKS)0111.pptx
API_Gateways_&_API_Security-1(API Securities and Gateway).pptx
Digital Signature in CryptographyElgammal
Genetic_Algorithms(1,2,3,4,5)_ML_AI_DS.ppt
Ad

Recently uploaded (20)

PPTX
Pharma ospi slides which help in ospi learning
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Cell Types and Its function , kingdom of life
PPTX
GDM (1) (1).pptx small presentation for students
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
O5-L3 Freight Transport Ops (International) V1.pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Pre independence Education in Inndia.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf
Pharma ospi slides which help in ospi learning
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
human mycosis Human fungal infections are called human mycosis..pptx
Anesthesia in Laparoscopic Surgery in India
Cell Types and Its function , kingdom of life
GDM (1) (1).pptx small presentation for students
PPH.pptx obstetrics and gynecology in nursing
STATICS OF THE RIGID BODIES Hibbelers.pdf
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
O5-L3 Freight Transport Ops (International) V1.pdf
Final Presentation General Medicine 03-08-2024.pptx
Chapter 2 Heredity, Prenatal Development, and Birth.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Pre independence Education in Inndia.pdf
Complications of Minimal Access Surgery at WLH
Module 4: Burden of Disease Tutorial Slides S2 2025
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
VCE English Exam - Section C Student Revision Booklet
Physiotherapy_for_Respiratory_and_Cardiac_Problems WEBBER.pdf

DATA TYPES in Python done by Sanajai of MCA

  • 2. Data Types in Java Data types specify the different sizes and values that can be stored in the variable. There are two types of data types in Java: Primitive data types: The primitive data types include boolean, char, byte, short, int, long, float and double. Non-primitive data types: The non-primitive data types include Classes, Interfaces, and Arrays.
  • 3. Java Primitive Data Types In Java language, primitive data types are the building blocks of data manipulation. These are the most basic data types available in java language. There are 8 types of primitive data types:  boolean data type  byte data type  char data type  short data type  int data type  long data type  float data type  double data type
  • 6. Boolean Data Type The Boolean data type is used to store only two possible values: true and false. This data type is used for simple flags that track true/false conditions. Example: Boolean one = false
  • 7. Example - 1 public class Main { public static void main(String[] args) { int myAge = 25; int votingAge = 18; System.out.println(myAge >= votingAge); // returns true (25 year olds are allowed to vote!) } } Output: true
  • 8. Byte Data Type The byte data type is an example of primitive data type. It is an 8-bit signed two's complement integer. Its value-range lies between -128 to 127. Its minimum value is -128 and maximum value is 127. Its default value is 0. Example: byte a = 10, byte b = -20
  • 9. Example - 1 public class Main { public static void main(String[] args) { byte myNum = 100; System.out.println(myNum); } } Output: 100
  • 10. Short Data Type The short data type is a 16-bit signed two's complement integer. Its value-range lies between -32,768 to 32,767 . Its minimum value is -32,768 and maximum value is 32,767. Its default value is 0. The short data type can also be used to save memory just like byte data type. A short data type is 2 times smaller than an integer. Example: short s = 10000, short r = -5000
  • 11. Example - 1 public class Main { public static void main(String[] args) { short myNum = 5000; System.out.println(myNum); } } Output: 5000
  • 12. Int Data Type The int data type is a 32-bit signed two's complement integer. Its value-range lies between - 2,147,483,648 to 2,147,483,647. Its minimum value is - 2,147,483,648 and maximum value is 2,147,483,647. Its default value is 0. Example: int a = 100000, int b = -200000
  • 13. Example - 1 public class Main { public static void main(String[] args) { int myNum = 100000; System.out.println(myNum); } } Output: 100000
  • 14. Long Data Type The long data type is a 64-bit two's complement integer. Its value- range lies between -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Its default value is 0. The long data type is used when you need a range of values more than those provided by int. Example: long a = 100000L, long b = -200000L
  • 15. Example - 1 public class Main { public static void main(String[] args) { long myNum = 15000000000L; System.out.println(myNum); } } Output: 15000000000
  • 16. Float Data Type The float data type is a single-precision 32-bit floating point. Its value range is unlimited. It is recommended to use a float if you need to save memory in large arrays of floating point numbers. The float data type should never be used for precise values, such as currency. Its default value is 0.0F. Example: float f1 = 234.5f
  • 17. Example - 1 public class Main { public static void main(String[] args) { float myNum = 5.75f; System.out.println(myNum); } } Output: 5.75
  • 18. Char Data Type The char data type is a single 16-bit Unicode character. Its value- range lies between 'u0000' (or 0) to 'uffff'. The char data type is used to store characters. Example: char letterA = 'A'
  • 19. Example - 1 public class Main { public static void main(String[] args) { char myGrade = 'B'; System.out.println(my Grade); } } Output: B
  • 20. Double Data Type The double data type is a double-precision 64-bit floating point. Its value range is unlimited. The double data type is generally used for decimal values just like float. The double data type also should never be used for precise values, such as currency. Its default value is 0.0d. Example: double d1 = 12.3
  • 21. Example - 1 public class Main { public static void main(String[] args) { double myNum = 19.99d; System.out.println(myNum); } } Output: 19.99