1. రెండు రకాల వ్యాఖ్యలు

పైన చెప్పినదానికి మనం కొన్ని పదాలను జోడించాలి.

జావాలో, మీరు ఆదేశాలను వ్రాయవచ్చు, కానీ మీరు కోడ్‌లోనే ఆ ఆదేశాలకు వ్యాఖ్యలను కూడా జోడించవచ్చు. కంపైలర్ వ్యాఖ్యలను పూర్తిగా విస్మరిస్తుంది. ప్రోగ్రామ్ రన్ అయినప్పుడు, అన్ని వ్యాఖ్యలు విస్మరించబడతాయి.

ఇక్కడ ఒక ఉదాహరణ:

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");
   }
}

ఇక్కడ, కోడ్‌తో మొదలై //పంక్తి చివరి వరకు ఉన్న కోడ్ //వ్యాఖ్యగా పరిగణించబడుతుంది. మరో మాటలో చెప్పాలంటే, 'వ్యాఖ్యను పూర్తి చేయడానికి' రెండవ జత గుర్తులు ఉపయోగించబడవు.


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.

అవును, కొన్ని వ్యాఖ్యలు చాలా ఫన్నీగా ఉన్నాయి.