জাভা মন্তব্যগুলি এমন বিবৃতি যা কম্পাইলার এবং দোভাষী দ্বারা কার্যকর করা হয় না৷ মন্তব্যগুলি পরিবর্তনশীল, পদ্ধতি, শ্রেণী বা যেকোনো বিবৃতি সম্পর্কে তথ্য প্রদান করতে ব্যবহার করা যেতে পারে। এটি একটি নির্দিষ্ট সময়ের জন্য প্রোগ্রাম কোড লুকানোর জন্যও ব্যবহার করা যেতে পারে।
জাভা মন্তব্যের প্রকারগুলি
জাভাতে তিন ধরনের মন্তব্য আছে।
- একক লাইন মন্তব্য
- মাল্টি-লাইন মন্তব্য
- ডকুমেন্টেশন মন্তব্য
একক লাইন মন্তব্য
একক লাইনের মন্তব্য // দিয়ে শুরু হয় এবং লাইনের শেষে শেষ হয়।
উদাহরণ 1
public class SingleLineComment { public static void main(String[] args) { // To print output in the console System.out.println("Welcome to Tutorials Point"); } }
আউটপুট
Welcome to Tutorials Point
মাল্টি-লাইন মন্তব্য
মাল্টি-লাইন মন্তব্য /* দিয়ে শুরু হয় এবং */ দিয়ে শেষ হয় যা একাধিক লাইন বিস্তৃত করে।
উদাহরণ 2
public class MultiLineComment { public static void main(String[] args) { /* To print the output as Welcome to Tutorials Point in the console. */ System.out.println("Welcome to Tutorials Point"); } }
আউটপুট
Welcome to Tutorials Point
ডকুমেন্টেশন মন্তব্য
ডকুমেন্টেশন শৈলী মন্তব্য /** দিয়ে শুরু হয় এবং */ দিয়ে শেষ হয় এবং এটি একাধিক লাইন বিস্তৃত হয়। ডকুমেন্টেশন মন্তব্যগুলি অবশ্যই একটি ক্লাস বা একটি ইন্টারফেস বা একটি পদ্ধতি বা একটি ক্ষেত্রের সংজ্ঞার আগে অবিলম্বে আসতে হবে৷
উদাহরণ 3
/** This is a documentation comment. This class is written to show the use of documentation comment in Java. This program displays the text "Welcome to Tutorials Point" in the console. */ public class DocumentationComment { public static void main(String args[]) { System.out.println("Welcome to Tutorials Point"); } }
আউটপুট
Welcome to Tutorials Point