Java Tutorial Package, Class, Method Definition Part 1.1

Published: 28 May 2023
on channel: myideaink
340
2

जावा पैकेज (Java Package) एक तरीका है जिससे हम अपनी जावा कोड को organize/structure तकरते हैं। पैकेज एक namespace होता है जिसमें Classes, इंटरफेस Interfaces, और अन्य यूनिट्स.
for example enums होती हैं। पैकेज के naming यूनिक और identifiable hona chahiye | ताकि अलग-अलग पैकेजों में classes और अन्य यूनिट्स को अलग किया जा सके।

पैकेज का उपयोग जावा कोड को (Hierarchy) और व्यवस्थित करने में मदद करता है। पैकेजों का उपयोग करके, हम जावा कोड को विभाजित कर सकते हैं और अलग-अलग लॉजिकल units में संगठित कर सकते हैं।
इससे प्रोग्राम को समझने, structure, और develop करने में आसानी होती है।
जब हम एक पैकेज बनाते हैं, तो हमें naming का पालन करना चाहिए जिसमें यदि हमारा दृष्टिकोण कम्पनी का नाम है, तो उसके बाद organization के लिए एक यूनिक नाम, और इसके बाद project का एक यूनिक नाम हो सकता है।
उदाहरण के लिए, कम्पनी का नाम com.example हो सकता है, uske bad project हो सकता है, then logical struccure का नाम util हो सकता है।
final package name com.example.project.util hon sakta hai.


जावा क्लास एक ब्लूप्रिंट होती है जिससे हम ऑब्जेक्ट बना सकते हैं। जब हम किसी क्लास को डिफ़ाइन करते हैं, तो हम उस क्लास के लिए variables और उनके साथ-साथ विभिन्न मेथड्स ya (फ़ंक्शन) को परिभाषित करते हैं।
इन variables और मेथड्स को हम क्लास के 'मेम्बर' कहते हैं। जब हम एक क्लास का ऑब्जेक्ट बनाते हैं, तो हम उस क्लास में define की गई variables और मेथड्स को इस ऑब्जेक्ट के लिए उपयोग कर सकते हैं।
अपने क्लास के as per use, हम एक या अधिक ऑब्जेक्ट्स बना सकते हैं और उन्हें different ऑपरेशन्स के लिए इस्तेमाल कर सकते हैं।
जावा क्लास एक important concept hai जो ऑब्जेक्ट-ओरिएंटेड प्रोग्रामिंग की fundamentals में से एक है। क्लासेस कोड को organize करने में important role play karta है और हमें प्रोग्राम को बेहतर ढंग से समझने और
structure करने में मदद करती हैं।


The Java main method is a special method that exists in every Java program.
It serves as the entry point of the program where the execution of the program begins.
When we run a Java program, the Java Virtual Machine (JVM) looks for the main method and starts executing it.
The main method is a public, static, and void method. It doesn't have a specific task, but its purpose is to start the execution of the program.
The structure of the main method is as follows:


In Java, a method is a block of code that performs a specific task. It is a collection of statements that are grouped together and given a name, which can be used to invoke or call the method when needed.

Methods are used to organize and modularize code, making it easier to understand, reuse, and maintain. They provide a way to break down complex tasks into smaller, more manageable parts.

Here are some key points to understand about methods in Java:

Method Declaration: A method is declared with a signature that includes the method name, return type, and parameters (if any). The return type specifies the type of value the method will return, or it can be declared as void if the method does not return any value.

Method Parameters: Parameters are variables that are passed into a method. They provide a way to pass values from the calling code to the method. Methods can have zero or more parameters, and each parameter has a type and a name.

Method Body: The method body contains the code that is executed when the method is called. It is enclosed in curly braces {} and can include any valid Java statements.

Method Invocation: To use a method, you need to invoke or call it. This is done by using the method name followed by parentheses (). If the method has parameters, you pass the appropriate values within the parentheses.

Return Statement: If a method has a return type other than void, it must use the return statement to return a value of that type. The return statement also terminates the method execution.

Method Overloading: Java supports method overloading, which means you can define multiple methods with the same name but different parameters. The compiler determines which method to invoke based on the arguments passed during the method call.


In Java, System.out.println is a predefined method that is used to print output to the console.
It is part of the java.lang package, so you don't need to import any additional packages to use it.
The System.out.println statement prints the specified message or value followed by a line break.
It is commonly used to display information, debug messages, or the result of a computation.
The syntax of the System.out.println statement is as follows:

System.out.println(message);
Here, message can be a string, a variable, or an expression that you want to print.
It can also be concatenated with other strings or variables using the + operator.


The System.out.println statement is useful for displaying information during program execution and is commonly used for debugging and providing feedback to the user.


On this page of the site you can watch the video online Java Tutorial Package, Class, Method Definition Part 1.1 with a duration of hours minute second in good quality, which was uploaded by the user myideaink 28 May 2023, share the link with friends and acquaintances, this video has already been watched 340 times on youtube and it was liked by 2 viewers. Enjoy your viewing!