Posts

Showing posts from November, 2023

Operator Precedence in Java जावा में ऑपरेटर की प्राथमिकता

In Java, operators are evaluated in a specific order called precedence . When an expression has multiple operators, the precedence rules determine which operator is executed first. जावा में जब किसी अभिव्यक्ति (expression) में कई ऑपरेटर होते हैं, तो उनकी प्राथमिकता यह तय करती है कि कौन सा ऑपरेटर पहले कार्य करेगा। 📌 Operators with higher precedence are evaluated before those with lower precedence. 📌 अधिक प्राथमिकता वाले ऑपरेटर पहले निष्पादित होते हैं। 🔝 Operator Precedence Table (Highest to Lowest) (उच्च से निम्न प्राथमिकता तक ऑपरेटर) 1️⃣ Postfix Operators (पोस्टफिक्स ऑपरेटर) expr++ (Post-increment) expr-- (Post-decrement) int a = 5; int b = a++; // b = 5, a = 6 2️⃣ Unary Operators (यूनरी ऑपरेटर) ++expr , --expr (Pre-increment, Pre-decrement) +expr , -expr (Unary plus, minus) !expr (Logical NOT), ~expr (Bitwise NOT) (type) expr (Type casting) int x = -10; int y = +x; // y = -10 3️⃣ Multiplicative Operators (गुणन ऑपरेटर) * , / , % int a = 6, b = 4; Syste...

Operators in java जावा में ऑपरेटर

In Java, operators are special symbols used to perform operations on variables and values. Java supports the following types of operators: जावा में, ऑपरेटर विशेष चिह्न होते हैं जो वेरिएबल्स और मानों पर संचालन (ऑपरेशन) करते हैं। जावा निम्न प्रकार के ऑपरेटरों का समर्थन करता है: 1️⃣ Arithmetic Operators (गणितीय ऑपरेटर) Used for basic mathematical operations. इनका उपयोग गणनाएँ करने के लिए किया जाता है। Operator Meaning Example + Addition a + b - Subtraction a - b * Multiplication a * b / Division a / b % Modulus a % b 🔸 Example: int a = 10, b = 3; System.out.println(a + b); // 13 System.out.println(a % b); // 1 2️⃣ Relational or Comparison Operators (तुलनात्मक ऑपरेटर) Used to compare two values. दो मानों की तुलना करने के लिए प्रयुक्त। Operator Meaning Example == Equal to a == b != Not equal to a != b > Greater than a > b < Less than a < b >= Greater than or equal a >= b <= Less than or...

Type Casting (Type Conversion) in Java जावा में टाइप कास्टिंग (टाइप कन्वर्शन)

Type casting or Type Conversion refers to the process of converting one data type into another within a specific statement or expression. In Java, there are two main types of type casting: टाइप कास्टिंग या टाइप कन्वर्शन के अंतर्गत किसी विशेष स्टेटमेंट या एक्सप्रेशन में एक डेटा टाइप को दूसरे डेटा टाइप में बदला जाता है। जावा में टाइप कास्टिंग के दो मुख्य प्रकार होते हैं: a) Widening Casting (Implicitly) वाइडनिंग कास्टिंग (स्वचालित रूप से) :- Converting a smaller data type into a larger data type is called widening casting or implicit casting . एक छोटे डेटा टाइप को बड़े डेटा टाइप में परिवर्तित करना वाइडनिंग कास्टिंग या स्वचालित कास्टिंग कहलाता है। Conversion order (रूपांतरण क्रम): byte → short → char → int → long → float → double Example / उदाहरण: int i = 5; double j = i; // Implicit casting - from int to double System.out.println(i); // Output: 5 System.out.println(j); // Output: 5.0 b) Narrowing Casting (Manually) नैरोविंग कास्टिंग (मैन्युअली) :- Converting a l...

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   ...

Scope of a variable in java जावा में वेरिएबल का कार्यक्षेत्र

In Java, the scope of a variable refers to the region in a program where the variable is recognized and accessible. Variables in Java can be categorized based on their scope into three main types: जावा में वेरिएबल का कार्यक्षेत्र उस हिस्से को कहा जाता है जहाँ वेरिएबल मान्य और उपयोग योग्य होता है। जावा में वेरिएबल के कार्यक्षेत्र को तीन प्रमुख वर्गों में बांटा गया है– 1️⃣ Local Variable (लोकल वेरिएबल) English: Declared and used only inside a method or a block {} . Scope is limited to that method or block. Dies as soon as the control exits the method. Java does not allow same-name variables in nested blocks unlike C/C++. Hindi: यह किसी मेथड या ब्लॉक {} के अंदर ही घोषित और उपयोग किए जाते हैं। इनका कार्यक्षेत्र उसी मेथड या ब्लॉक तक सीमित होता है। जैसे ही कंट्रोल बाहर जाता है, यह समाप्त हो जाते हैं। जावा में नेस्टेड ब्लॉक्स में एक ही नाम के दो वेरिएबल नहीं बनाए जा सकते हैं। 2️⃣ Instance Variable (इंस्टैंस वेरिएबल) English: Declared inside a class but...

Variables in Java जावा में वेरिएबल

In Java, a variable is a named storage location used to hold data values during program execution. Variables are essential because they allow you to store, update, and use data dynamically. जावा में वेरिएबल (चर) एक नामित स्टोरेज स्थान होता है, जिसका उपयोग प्रोग्राम के दौरान डेटा को संग्रहित और उपयोग करने के लिए किया जाता है। वेरिएबल्स प्रोग्रामिंग का एक मूलभूत हिस्सा होते हैं। 🔹 1. Declaration | घोषणा Before using a variable, it must be declared with its data type and name. किसी वेरिएबल का उपयोग करने से पहले, उसका डेटा प्रकार और नाम बताकर उसे घोषित (declare) करना होता है। int age; // Declare an integer variable named 'age' 🔹 2. Initialization | मान देना After declaring, you can assign a value. This is called initialization . घोषणा के बाद, वेरिएबल को कोई मान (value) देना Initialization कहलाता है। age = 50; // Initialize the variable Declaration and initialization can also be done together: int age = 50; 🔹 3. Variable Types | वेरिएबल के प्रकार Java is stati...

Constants (Literal) in Java जावा में स्थिरांक

In Java, a constant is a variable whose value cannot be changed once assigned. Constants are used to represent fixed values that remain unchanged during the program’s execution. In Java, constants are declared using the final keyword. जावा में, स्थिरांक (constant) एक ऐसा वेरिएबल होता है जिसका मान एक बार निर्धारित हो जाने के बाद बदला नहीं जा सकता है। स्थिरांकों का उपयोग ऐसे मानों को दर्शाने के लिए किया जाता है जो प्रोग्राम के निष्पादन के दौरान हमेशा एक जैसे रहते हैं। जावा में, कॉन्स्टेंट्स को final कीवर्ड से घोषित किया जाता है। 📌 Syntax (सिंटैक्स):- final dataType CONSTANT_NAME = value; Example (उदाहरण): final double PI = 3.14159; 🌐 Global Constants in Java | वैश्विक स्थिरांक In Java, a global constant refers to a value that can be accessed throughout a class or even across multiple classes in the same package. Such constants are generally declared using both the static and final keywords. जावा में, वैश्विक स्थिरांक (Global Constant) ऐसा मान होता है जिसे किसी एक क्लास या एक ही ...

Java Programming Style जावा प्रोग्रामिंग की शैली

Programming style is a set of guidelines applied to use the instructions of a programming language correctly. Following a programming style is crucial because it helps the programmer understand the code easily, and it reduces the chances of errors. प्रोग्रामिंग शैली, किसी प्रोग्रामिंग लैंग्वेज के निर्देशों को सही तरीके से उपयोग करने के लिए लागू किए गए दिशानिर्देशों का एक समूह होता है। एक प्रोग्रामिंग शैली का पालन करना अत्यंत आवश्यक होता है क्योंकि इसकी सहायता से प्रोग्रामर कोड को आसानी से समझ सकता है एवं कम त्रुटियां उत्पन्न होती हैं। Important Rules of Java Programming Style | जावा प्रोग्रामिंग शैली के महत्वपूर्ण नियम: 1️⃣ A Java program should be easy to read and understand. एक जावा प्रोग्राम पढ़ने एवं समझने में आसान होना चाहिए। 2️⃣ Each class should have Javadoc comments and @author tag. प्रत्येक क्लास में जावाडॉक टिप्पणी एवं @author टैग होना चाहिए। 3️⃣ Each public method should have Javadoc comments. हर पब्लिक मेथड में जावाडॉक टिप्पणी होनी चाहिए। 4️⃣ Variables should inc...

Java Environment जावा का वातावरण

Introduction | परिचय  To develop and run Java applications, a complete setup is needed that includes development tools and a runtime system. This environment is known as the Java Environment and consists mainly of the JDK, JRE, and JVM. जावा एप्लिकेशन को विकसित और रन करने के लिए एक सम्पूर्ण वातावरण की आवश्यकता होती है, जिसमें डेवलपमेंट टूल्स और रनटाइम सिस्टम शामिल होता है। इसे ही जावा का वातावरण कहा जाता है, जिसमें मुख्यतः JDK, JRE और JVM होते हैं। 1️⃣ Java Development Kit (JDK) | जावा डेवलपमेंट किट JDK is a software development environment used to build Java applications and applets. It includes: Java Runtime Environment (JRE) – to run applications javac – Java compiler java – Interpreter/Loader jar – Java Archive tool javadoc – Documentation generator JDK एक सॉफ्टवेयर डेवलपमेंट वातावरण है जिसका उपयोग जावा एप्लिकेशन और एप्लेट्स को बनाने के लिए किया जाता है। इसमें शामिल हैं: Java Runtime Environment (JRE) – एप्लिकेशन चलाने हेतु javac – जावा कंपाइलर ...