Operators, Literals এবং Keywords in Java সম্পূর্ণ বাংলা ভাষায় শিখুন | Java Programming Part -3
4 minute read
Operators, Literals এবং Keywords in Java সম্পূর্ণ বাংলা ভাষায় শিখুন | Java Programming Part -3
![]() |
Operators, Literals, Keywords in Java |
Operators
জাভা প্রোগ্রামিং ভাষায়, Operator-গুলি Variable এবং তার Value-র উপর কাজ করতে ব্যবহার করা হয়।
প্রথমে, Data type এবং Variable-র কয়েকটি উদাহরণ দেখি।
int a = 10;
char c = 'a';
String name = 'Java' ;
boolean b = true;
এখানে int, char, String, boolean হল Data type এবং a, c, name, b হল Variable ।
আমি যদি লিখি c = a + b;
তবে এখানে '=' এবং '+' দুটি হল operators, 'a' এবং 'b' দুটি হল operands।
সুতরাং operators হল বিশেষ চিহ্ন '+', '-', '*', '/', '<', '>', '=' ইত্যাদি।
বিভিন্ন ধরনের Operators
Arithmetic Operators:
+ (Addition)
: দুটি মান যোগ করে।- (Subtraction)
: একটি মান থেকে অন্যটি বিয়োগ করে।* (Multiplication)
: দুটি মান গুণ করে।/ (Division)
: একটি মান অন্যটি দ্বারা ভাগ করে।% (Modulus)
: একটি মান অন্যটি দ্বারা ভাগ করলে অবশিষ্ট ভাগশেষ দেয়।++ (Increment)
: একটি ভেরিয়েবলের মান এক বাড়ায়।-- (Decrement)
: একটি ভেরিয়েবলের মান এক কমায়।
Assignment Operators:
= (Equal)
: একটি ভেরিয়েবলে মান অ্যাসাইন করে।+= (Pluse equal)
: একটি ভেরিয়েবলে মান যোগ করে।-= (- equal)
: একটি ভেরিয়েবলে মান বিয়োগ করে।*=
: একটি ভেরিয়েবলে মান গুণ করে।/=
: একটি ভেরিয়েবলে মান ভাগ করে।%=
: একটি ভেরিয়েবলে মান ভাগ করলে অবশিষ্ট ভাগশেষ দেয়।
Comparison Operators:
== (Equal to)
: দুটি মান সমান কিনা তা পরীক্ষা করে।!= (Not Equal)
: দুটি মান সমান না কিনা তা পরীক্ষা করে।> (Greater than)
: একটি মান অন্যটির চেয়ে বড় কিনা তা পরীক্ষা করে।< (Less than)
: এএকটি মান অন্যটির চেয়ে ছোট কিনা তা পরীক্ষা করে।- Logical Operators:
- && (Logical or) : উভয় বিবৃতি সত্য হলে সত্য প্রদান করে।
- || (Logical or) : বিবৃতিগুলির একটি সত্য হলে সত্য প্রদান করে।
- ! (Logical not) : ফলাফল বিপরীত, ফলাফল সত্য হলে মিথ্যা প্রদান করে (Reverse the result)।
Literals
যে কোনো value যা আপনি Variable-কে assign করবেন, ওই value-টিকে Literal বলে।
উদাহরণ : int a = 10;
এখানে a-র value 10 অথবা 10-কে a variable -এ assign করা হয়েছে।
আরো দেখুন,
char c = 'a';
String name = 'Java' ;
boolean b = true;
এখানে a, Java, true সব literals ।
বিভিন্ন ধরনের Literals
Keywords
Keywords হচ্ছে কিছু predefine word যা সংরক্ষণ করে রাখা হয়েছে program করার জন্য। প্রতিটি keywords-র আছে আলাদা আলাদা কাজ। যখনি আমরা কোনো progamming language শিখতে শুরু করি, সেখানে কিছু words আগে থেকেই ওই language-এর তালিকায় থাকে। ওই তালিকায় যে words-গুলি থাকে তাদের keywords বলে।
java-তে 50 টি keywords আছে।
50 টি keywords-র মধ্য 48 keywords আমরা ব্যবহার করি। দুটি keywords 'goto' এবং 'const' ব্যবহার করি না। তিনটি predefined words যথা- true, false, null কে literals হিসেবে ব্যবহার করা হয়।
50 keywords এবং ৩টি literals কে identifiers হিসেবে ব্যবহার করা যায় না।
- abstract: Used to declare a class or method that is incomplete and must be implemented by subclasses or concrete methods.
- assert: Used to test a condition and throw an error if the condition is false.
- boolean: A primitive data type representing true or false values.
- break: Used to exit a loop or switch statement.
- byte: A primitive data type representing 8-bit signed integers.
- case: Used in switch statements to define different cases.
- catch: Used to handle exceptions thrown by try blocks.
- char: A primitive data type representing a single 16-bit Unicode character.
- class: Used to declare a class.
- continue: Used to skip the current iteration of a loop and proceed to the next iteration.
- default: Used in switch statements as the default case.
- do: Used to start a do-while loop.
- double: A primitive data type representing double-precision 64-bit floating-point numbers.
- else: Used in conditional statements to execute code when the if condition is false.
- enum: Used to declare an enumeration, which is a special type of class that represents a group of constants.
- extends: Used to create a subclass that inherits properties and methods from a superclass.
- final: Used to declare constants, prevent method overriding, and define immutable classes.
- finally: Used in exception handling to execute code regardless of whether an exception is thrown or not.
- float: A primitive data type representing single-precision 32-bit floating-point numbers.
- for: Used to create a for loop.
- if: Used to create conditional statements.
- implements: Used to implement an interface in a class.
- import: Used to import classes, interfaces, or packages.
- instanceof: Used to test whether an object is an instance of a particular class or interface.
- int: A primitive data type representing 32-bit signed integers.
- interface: Used to declare an interface, which defines a contract for classes that implement it.
- long: A primitive data type representing 64-bit signed integers.
- native: Used to declare native methods, which are implemented in platform-dependent code.
- new: Used to create new objects.
- null: A literal representing a null reference.
- package: Used to declare a package, which is a namespace for organizing classes and interfaces.
- private: Access modifier used to restrict access to members within the same class.
- protected: Access modifier used to restrict access to members within the same package or subclasses.
- public: Access modifier used to allow unrestricted access to members.
- return: Used to exit a method and return a value.
- short: A primitive data type representing 16-bit signed integers.
- static: Modifier used to declare static fields, methods, and nested classes.
- strictfp: Modifier used to restrict floating-point calculations to ensure portability.
- super: Used to refer to the superclass of the current object.
- switch: Used to create a switch statement.
- synchronized: Modifier used to restrict access to a block of code to only one thread at a time.
- this: Used to refer to the current object.
- throw: Used to explicitly throw an exception.
- throws: Used to declare the exceptions that a method may throw.
- transient: Modifier used to indicate that a field should not be serialized.
- try: Used to start a block of code that may throw exceptions.
- void: Used to declare that a method does not return a value.
- volatile: Modifier used to indicate that a variable may be modified asynchronously.
- while: Used to create a while loop.
Post a Comment