-->

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

  1. Arithmetic Operators:

    • + (Addition): দুটি মান যোগ করে।
    • - (Subtraction): একটি মান থেকে অন্যটি বিয়োগ করে।
    • * (Multiplication): দুটি মান গুণ করে।
    • / (Division): একটি মান অন্যটি দ্বারা ভাগ করে।
    • % (Modulus): একটি মান অন্যটি দ্বারা ভাগ করলে অবশিষ্ট ভাগশেষ দেয়।
    • ++ (Increment): একটি ভেরিয়েবলের মান এক বাড়ায়।
    • -- (Decrement): একটি ভেরিয়েবলের মান এক কমায়।
  2. Assignment Operators:

    • = (Equal): একটি ভেরিয়েবলে মান অ্যাসাইন করে।
    • += (Pluse equal): একটি ভেরিয়েবলে মান যোগ করে।
    • -= (- equal): একটি ভেরিয়েবলে মান বিয়োগ করে।
    • *=: একটি ভেরিয়েবলে মান গুণ করে।
    • /=: একটি ভেরিয়েবলে মান ভাগ করে।
    • %=: একটি ভেরিয়েবলে মান ভাগ করলে অবশিষ্ট ভাগশেষ দেয়।
  3. Comparison Operators:

    • == (Equal to): দুটি মান সমান কিনা তা পরীক্ষা করে।
    • != (Not Equal): দুটি মান সমান না কিনা তা পরীক্ষা করে।
    • > (Greater than): একটি মান অন্যটির চেয়ে বড় কিনা তা পরীক্ষা করে।
    • < (Less than): এএকটি মান অন্যটির চেয়ে ছোট কিনা তা পরীক্ষা করে।
  4. 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

Image-10: 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 হিসেবে ব্যবহার করা যায় না।
  1. abstract: Used to declare a class or method that is incomplete and must be implemented by subclasses or concrete methods.
  2. assert: Used to test a condition and throw an error if the condition is false.
  3. boolean: A primitive data type representing true or false values.
  4. break: Used to exit a loop or switch statement.
  5. byte: A primitive data type representing 8-bit signed integers.
  6. case: Used in switch statements to define different cases.
  7. catch: Used to handle exceptions thrown by try blocks.
  8. char: A primitive data type representing a single 16-bit Unicode character.
  9. class: Used to declare a class.
  10. continue: Used to skip the current iteration of a loop and proceed to the next iteration.
  11. default: Used in switch statements as the default case.
  12. do: Used to start a do-while loop.
  13. double: A primitive data type representing double-precision 64-bit floating-point numbers.
  14. else: Used in conditional statements to execute code when the if condition is false.
  15. enum: Used to declare an enumeration, which is a special type of class that represents a group of constants.
  16. extends: Used to create a subclass that inherits properties and methods from a superclass.
  17. final: Used to declare constants, prevent method overriding, and define immutable classes.
  18. finally: Used in exception handling to execute code regardless of whether an exception is thrown or not.
  19. float: A primitive data type representing single-precision 32-bit floating-point numbers.
  20. for: Used to create a for loop.
  21. if: Used to create conditional statements.
  22. implements: Used to implement an interface in a class.
  23. import: Used to import classes, interfaces, or packages.
  24. instanceof: Used to test whether an object is an instance of a particular class or interface.
  25. int: A primitive data type representing 32-bit signed integers.
  26. interface: Used to declare an interface, which defines a contract for classes that implement it.
  27. long: A primitive data type representing 64-bit signed integers.
  28. native: Used to declare native methods, which are implemented in platform-dependent code.
  29. new: Used to create new objects.
  30. null: A literal representing a null reference.
  31. package: Used to declare a package, which is a namespace for organizing classes and interfaces.
  32. private: Access modifier used to restrict access to members within the same class.
  33. protected: Access modifier used to restrict access to members within the same package or subclasses.
  34. public: Access modifier used to allow unrestricted access to members.
  35. return: Used to exit a method and return a value.
  36. short: A primitive data type representing 16-bit signed integers.
  37. static: Modifier used to declare static fields, methods, and nested classes.
  38. strictfp: Modifier used to restrict floating-point calculations to ensure portability.
  39. super: Used to refer to the superclass of the current object.
  40. switch: Used to create a switch statement.
  41. synchronized: Modifier used to restrict access to a block of code to only one thread at a time.
  42. this: Used to refer to the current object.
  43. throw: Used to explicitly throw an exception.
  44. throws: Used to declare the exceptions that a method may throw.
  45. transient: Modifier used to indicate that a field should not be serialized.
  46. try: Used to start a block of code that may throw exceptions.
  47. void: Used to declare that a method does not return a value.
  48. volatile: Modifier used to indicate that a variable may be modified asynchronously.
  49. while: Used to create a while loop.