Primitive Data Types in Java | Easy Tamil Explanation ๐ฅ
Follow us on Instagram: https://www.instagram.com/siyatechtales/?hl=en ------------------------------------- In Java, data types specify the size and type of values that can be stored in variables. They can be broadly categorized into Primitive Data Types and Reference/Object Data Types. -------------------------------------------------- Primitive Data Types Primitive data types are predefined by the language and are named by a keyword. They are the simplest forms of data types and include: byte short int long float double char boolean 1. byte Size: 1 byte (8 bits) Range: -128 to 127 Description: Stores small integer values. Useful for saving memory in large arrays. Example: java Copy code public class Main { public static void main(String[] args) { byte num = 100; System.out.println("Byte value: " + num); } } 2. short Size: 2 bytes (16 bits) Range: -32,768 to 32,767 Description: Stores integer values. It is also used to save memory as it is smaller than int. Example: java Copy code public class Main { public static void main(String[] args) { short num = 30000; System.out.println("Short value: " + num); } } 3. int Size: 4 bytes (32 bits) Range: -2^31 to 2^31 - 1 (i.e., -2,147,483,648 to 2,147,483,647) Description: Default data type for integer values. Example: java Copy code public class Main { public static void main(String[] args) { int num = 100000; System.out.println("Int value: " + num); } } 4. long Size: 8 bytes (64 bits) Range: -2^63 to 2^63 - 1 (i.e., -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807) Description: Used for large integer values beyond the range of int. Example: java Copy code public class Main { public static void main(String[] args) { long num = 10000000000L; // 'L' at the end is necessary to denote a long value System.out.println("Long value: " + num); } } 5. float Size: 4 bytes (32 bits) Range: Approximately ยฑ3.40282347E+38F (6-7 decimal digits precision) Description: Used for single-precision floating-point numbers (decimal values). Use F to denote a float. Example: java Copy code public class Main { public static void main(String[] args) { float num = 3.14F; // 'F' is needed to denote a float literal System.out.println("Float value: " + num); } } 6. double Size: 8 bytes (64 bits) Range: Approximately ยฑ1.79769313486231570E+308 (15 decimal digits precision) Description: Used for double-precision floating-point numbers. It is the default type for decimal values. Example: java Copy code public class Main { public static void main(String[] args) { double num = 3.14159; System.out.println("Double value: " + num); } } 7. char Size: 2 bytes (16 bits) Range: 0 to 65,535 (Unicode values) Description: Stores a single 16-bit Unicode character. Used to store any character (letter, number, symbol). Example: java Copy code public class Main { public static void main(String[] args) { char letter = 'A'; System.out.println("Char value: " + letter); } } 8. boolean Size: 1 bit (theoretically, but in reality, it might take up more space depending on JVM implementation) Range: true or false Description: Used to store logical values (true or false). Example: java Copy code public class Main { public static void main(String[] args) { boolean isJavaFun = true; System.out.println("Boolean value: " + isJavaFun); } } --------------------------------------------- Copyright Disclaimer under Section 52 of the Copyright Act, 1957 (India): This video is made for educational, informational, and entertainment purposes only. The content is transformative in nature, and its use is considered fair use under Indian copyright law. No copyright infringement is intended, and all rights belong to their respective owners. The purpose of this video is to educate, inform, and entertain, and it is not intended to harm or exploit any individual or entity. If you have any concerns or objections, please contact us at [email protected] -------------------- #java #datatypesinjava #codinginterview
Download
1 formatsVideo Formats
Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.