Posts

Showing posts with the label java tutorial for beginners

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) ऐसा मान होता है जिसे किसी एक क्लास या एक ही ...