Data types in Java जावा में डेटा के प्रकार

In Java, data types are used to specify the kind of data a variable can store. Understanding data types is fundamental to writing error-free and efficient code.

जावा में, डेटा प्रकार यह निर्धारित करते हैं कि कोई वेरिएबल किस प्रकार का डेटा संग्रहीत कर सकता है। प्रभावी प्रोग्रामिंग के लिए डेटा प्रकारों की समझ आवश्यक है।


1️⃣ Primitive Data Types आदिम डेटा प्रकार

Primitive data types store simple and direct values. Java supports 8 primitive data types:
आदिम डेटा प्रकार सीधे और सरल मान संग्रहीत करते हैं। जावा में 8 प्रकार के प्रिमिटिव डेटा टाइप होते हैं:

Data Type Size Range / Description डेटा प्रकार आकार सीमा / विवरण
byte 8-bit  -128 to 127 बाइट 8-बिट -128 से 127
short 16-bit   -32,768 to 32,767 शॉर्ट 16-बिट -32,768 से 32,767
int 32-bit  -2,147,483,648 to 2,147,483,647 इंट 32-बिट -2,14,74,83,648 से 2,14,74,83,647
long 64-bit  Very large integer values लॉन्ग 64-बिट बहुत बड़े पूर्णांक मान
float 32-bit    Decimal numbers (single precision) फ्लोट 32-बिट दशमलव संख्या (एकल सटीकता)
double 64-bit  Decimal numbers (double precision) डबल 64-बिट दशमलव संख्या (दोहरी सटीकता)
char 16-bit  Single Unicode character (e.g., 'A') कैरेक्टर 16-बिट एक यूनिकोड वर्ण
boolean 1-bit  true or false बूलियन 1-बिट true या false

Example:

byte myByte = 10;
short myShort = 1000;
int myInt = 100000;
long myLong = 1000000000L;

float myFloat = 3.14f;
double myDouble = 3.14159;

char myChar = 'A';
boolean myBoolean = true;

2️⃣ Reference Data Types संदर्भ डेटा प्रकार

These refer to objects in memory rather than storing the value directly. They store memory addresses that point to the actual data.
ये वेरिएबल डेटा को सीधे स्टोर नहीं करते, बल्कि उस डेटा के मेमोरी पते को स्टोर करते हैं।

a) String – A sequence of characters

स्ट्रिंग – वर्णों का क्रम

String myString = "Hello, Java!";

b) Array – A collection of elements of the same type

एरे – एक जैसे प्रकार के डेटा का संग्रह

int[] myArray = {1, 2, 3, 4, 5};

c) Class – User-defined data type

क्लास – उपयोगकर्ता द्वारा परिभाषित डेटा प्रकार

class Person {
    String name;
    int age;
}
Person myPerson = new Person();
myPerson.name = "John";
myPerson.age = 30;

d) Interface – Blueprint of methods

इंटरफ़ेस – विधियों का खाका

interface Shape {
    void draw();
}
class Circle implements Shape {
    public void draw() {
        System.out.println("Drawing a circle");
    }
}

Summary (सारांश):

Type Description
Primitive                       Stores basic values directly
Reference Stores reference to memory location

प्रकार विवरण
आदिम प्रकार                 मूल मान सीधे स्टोर करता है
संदर्भ प्रकार                 मेमोरी के पते को स्टोर करता है

These data types form the building blocks of Java programming. Mastering them is essential for writing logical, optimized, and bug-free code.
ये डेटा प्रकार जावा प्रोग्रामिंग के मूल स्तंभ हैं। इनकी समझ से आप बेहतर, तेज़ और सही प्रोग्रामिंग कर सकते हैं।

Comments

Popular posts from this blog

What is a Web Browser? वेब ब्राउज़र क्या है?

Java's Support System जावा का सहयोगी तंत्र

The Internet and Java इंटरनेट और जावा का सम्बन्ध