← Back to Core Java Course | Chapter 1: Introduction & Basics | Lesson 1 of 12

Java परिचय

Java एक programming language है जो हर तरह के programs बनाने के लिए उपयोग होती है, phone apps से लेकर बड़ी websites तक। यह एक universal language जैसी है जिसे कई अलग-अलग computers समझ सकते हैं।

What is Java?

Java एक class-based, object-oriented language है जिसे बहुत कम implementation dependencies रखने के लिए design किया गया है, मतलब code जो एक platform पर सही चलता है उसे minimal changes के साथ किसी भी दूसरे पर भी वैसे ही चलना चाहिए।

उदाहरण: What is Java?

java
// Define the class Main
public class Main {
	// Program entry point: the JVM starts running here
	public static void main(String[] args) {
		// Print a line to the console
		System.out.println("Java is class-based and object-oriented.");
	}
}

Write Once, Run Anywhere

WORA का मतलब है आप एक Java program को एक बार bytecode में compile करते हैं, फिर उसी bytecode को Windows, Linux, या macOS पर बिना फिर compile किए चलाते हैं -- JVM आपके लिए platform-specific translation handle करता है।

उदाहरण: Write Once, Run Anywhere

java
public class Main {
	// javac Main.java -> Main.class (bytecode)
	// java Main runs identically on Windows, Linux, or macOS
	public static void main(String[] args) {
		System.out.println("Same bytecode runs on any OS with a JVM.");
	}
}

How Java Works

आपकी .java source file javac द्वारा .class bytecode files में compile होती है, और Java Virtual Machine उस bytecode को पढ़ता है और इसे instructions में translate करता है जो आपका specific CPU execute कर सके।

उदाहरण: How Java Works

java
public class Main {
	// Step 1: Main.java (source)
	// Step 2: javac Main.java -> Main.class (bytecode)
	// Step 3: java Main -> JVM translates bytecode for your CPU
	public static void main(String[] args) {
		System.out.println("Compiled to bytecode, then run by the JVM.");
	}
}

Applications of Java

Java असली systems की एक बड़ी range को power देती है: Android app internals, banks और e-commerce companies में बड़े enterprise backends, और cloud services, काफी हद तक इसलिए क्योंकि इसका JVM और standard library scale पर mature और battle-tested हैं।

उदाहरण: Applications of Java

java
// Define the class Main
public class Main {
	// Program entry point: the JVM starts running here
	public static void main(String[] args) {
		String[] uses = {"Android app internals", "Enterprise backends", "Cloud services"};
		for (String use : uses) {
			// Print a line to the console
			System.out.println("Java powers: " + use);
		}
	}
}

Benefits of Java

Portability से आगे, Java को इसके garbage collector के ज़रिए automatic memory management (इसलिए आप शायद ही कभी memory manually manage करते हैं) और strict compile-time type checking के लिए value दी जाती है, जो program चलने से पहले ही कई bugs पकड़ती है।

उदाहरण: Benefits of Java

java
public class Main {
	public static void main(String[] args) {
		String text = "auto-managed"; // no manual free() - garbage collector handles it
		// int number = text; // fails at COMPILE time - type checking catches this early
		System.out.println("Memory is " + text + " by the garbage collector.");
	}
}
Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. Java को JavaScript के साथ confuse करना, जब वे अलग uses और syntax वाली अलग languages हैं।
  2. सिर्फ JRE install करना और code compile करने की उम्मीद करना, जब javac से compile करने के लिए JDK चाहिए।
  3. यह सोचना कि Java सीधे machine पर चलता है, जब source bytecode में compile होता है जिसे JVM चलाता है।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.