In Java, data types are used to define the type of data that a variable can hold. Java supports two types of data types:
जावा में, डेटा प्रकारों का उपयोग उस डेटा के प्रकार को परिभाषित करने के लिए किया जाता है जिसे एक वेरिएबल धारण कर सकता है। जावा दो प्रकार के डेटा प्रकारों का समर्थन करता है:
1. Primitive Data Types:- These are the basic data types that store simple values.
There are eight primitive data types in Java:-
1. आदिम डेटा प्रकार:- ये मूल डेटा प्रकार हैं जो सरल मान संग्रहीत करते हैं। जावा में आठ आदिम डेटा प्रकार हैं:-
byte 8-bit signed integer.
short 16-bit signed integer.
int 32-bit signed integer.
long 64-bit signed integer.
float 32-bit floating-point number.
double 64-bit floating-point number.
char 16-bit Unicode character.
boolean Represents true or false.
Examples:-
byte myByte = 10;
short myShort = 1000;
int myInt = 100000;
long myLong = 1000000000L; // Note the 'L' suffix for long literals
float myFloat = 3.14f; // Note the 'f' suffix for float literals
double myDouble = 3.14159;
char myChar = 'A';
boolean myBoolean = true;
2. Reference Data Types:- These data types refer to objects. Reference data types do not contain the actual data stored in a variable but contain a reference (memory address) to the location where the data is stored.like:-
2. संदर्भ डेटा प्रकार:- ये डेटा प्रकार वस्तुओं को संदर्भित करते हैं। संदर्भ डेटा प्रकारों में एक चर में संग्रहीत वास्तविक डेटा नहीं होता है बल्कि उस स्थान पर एक संदर्भ (मेमोरी पता) होता है जहां डेटा संग्रहीत होता है।जैसे:-
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 - Defines a set of methods.
इंटरफ़ेस - विधियों के एक सेट को परिभाषित करता है।
interface Shape {
void draw();}
class Circle implements Shape {
public void draw() {
System.out.println("Drawing a circle");
}
}
These data types provide the building blocks for writing Java programs, and understanding them is essential for effective programming in Java.
ये डेटा प्रकार जावा प्रोग्राम लिखने के लिए बिल्डिंग ब्लॉक प्रदान करते हैं, और जावा में प्रभावी प्रोग्रामिंग के लिए उन्हें समझना आवश्यक है।
No comments:
Post a Comment