1. दोन प्रकारच्या टिप्पण्या

वर सांगितलेल्या गोष्टींमध्ये आपण काही शब्द जोडले पाहिजेत.

Java मध्ये, तुम्ही कमांड्स लिहू शकता, परंतु तुम्ही कोडमध्ये त्या कमांड्सवर टिप्पण्या देखील जोडू शकता. कंपाइलर टिप्पण्यांकडे पूर्णपणे दुर्लक्ष करतो. प्रोग्राम चालवल्यावर, सर्व टिप्पण्या वगळल्या जातात.

येथे एक उदाहरण आहे:

public class Home
{
   public static void main (String[] args)
   {
      /*
      Now we'll display the phrase 'Amigo is the Best'
      */
      System.out.print("Amigo ");
      System.out.print("is the ");
      System.out.print("Best");
   }
}

आम्ही 'आता आम्ही वाक्यांश प्रदर्शित करू...' अशी टिप्पणी जोडली. टिप्पणीची सुरुवात चिन्हांच्या जोडीने दर्शविली जाते ( /*), आणि शेवट - ( */) द्वारे. जेव्हा प्रोग्राम संकलित केला जातो, तेव्हा कंपाइलर चिन्ह /*आणि मधील सर्व काही वगळतो*/

कमेंटमध्ये तुम्हाला हवे ते लिहू शकता.

सहसा, कोडमधील टिप्पण्या कोडच्या काही भागांबद्दल असतात ज्यांना समजणे कठीण असते. काही टिप्पण्यांमध्ये डझनभर स्ट्रिंग असतात: ते कसे कार्य करतात यामधील बारकावे वर्णन करण्याच्या पद्धतींपूर्वी या अनेकदा लिहिल्या जातात.

कोडवर टिप्पणी जोडण्याचा आणखी एक मार्ग आहे. तुम्ही दोन फॉरवर्ड स्लॅश ( ) वापरू शकता //.

public class Home
{
   public static void main (String[] args)
   {
      System.out.print("Amigo ");
      System.out.print("is the "); // This is also a comment
      System.out.print("Best");
   }
}

//येथे, the सह सुरू होणारा आणि ओळीच्या शेवटापर्यंतचा कोड //टिप्पणी मानला जातो. दुसऱ्या शब्दांत, 'टिप्पणी पूर्ण करण्यासाठी' वापरलेल्या चिन्हांची दुसरी जोडी नाही.


2. प्रोग्रामरच्या जीवनातील टिप्पण्या

तसे, काही टिप्पण्या खरोखर मनोरंजक आहेत.

// I'm not responsible for this code. I was forced to write it against my will.
// Dear, future me. Please forgive me for this code.
// If I see something like this once more, I'll have a complete mental breakdown at work.
// If this condition is ever satisfied, please inform me for a reward. Phone: xxx-xxx-xxx.
//
// Dear programmer:
//
// When you finish 'optimizing' this subroutine
// and realize what a huge mistake it was,
// please increment the following counter as a warning
// to the next guy:
//
// total_hours_wasted_here = 42
//
// When I wrote this, only God and I understood what I was doing
// Now only God knows.
// Sometimes it seems that the compiler is just ignoring all my comments
// I dedicate all my code and my work to my wife Darlene,
// who will have to provide for me, our three kids, and the dog when
// it gets released to the public.
// Magic. Don't touch.

होय, काही टिप्पण्या खूप मजेदार आहेत.