Java Comments

JK JK 2018 
Created at
Updated at  
8,001 0 0

In Java programming, clarity and readability are paramount. As developers craft intricate algorithms and intricate logic, the need for comprehensive explanations becomes evident. Enter Java comments – a simple yet powerful tool for annotating code and enhancing its comprehensibility.

 

"Code tells you how; Comments tell you why." - J. P. Sousa

 

Single-line Comments

Single-line comments start with two forward slashes (//).

Any text between // and the end of the line is ignored by Java (will not be executed).

This example uses a single-line comment before a line of code:

// This is a comment
System.out.println("Hello World");
System.out.println("Hello World"); // This is a comment

 

Java Multi-line Comments

Multi-line comments start with /* and ends with */.

Any text between /* and */ will be ignored by Java.

This example uses a multi-line comment (a comment block) to explain the code:

/* The code below will print the words Hello World
to the screen, and it is amazing */
System.out.println("Hello World");


Java comments serve as indispensable companions on the journey of software development. Whether elucidating individual lines of code or documenting entire systems, their role in fostering clarity and comprehension cannot be overstated. So, the next time you embark on a coding adventure, remember to let your comments shine – for they are the guiding lights in the realm of Java programming.

Tags J. P. Sousa Java Java Comments Java Multi-line Comments Java Single-line Comments Facebook X
Comments 0
Similar posts
  1. Java Variables
    7,461
  2. Java Math
    7,429
  3. The Print() Method
    7,148
  4. Java Syntax
    7,436
  5. Java If ... Else
    7,392
  6. Java Short Hand If...Else (Ternary Operator)
    7,572
  7. Java Switch Statements
    7,402
  8. Java While Loop/Do While Loop/For Loop/For-Each Loop/Break/Continue
    7,847
  9. Java Getting Started
    7,406
  10. Java Methods
    7,081
  11. Java Scope
    7,089
  12. Java Recursion
    7,197
  13. Java Classes and Objects
    7,078
  14. Java Packages
    7,174
  15. Java Inheritance (Subclass and Superclass)
    7,178
  16. Java Polymorphism
    7,052
  17. What is Java?
    7,088
  18. Java Inner Classes
    7,045
  19. Machine Learning Types and Programming Languages
    7,230
  20. Java Tutorials associated with AP Computer Science A
    7,599
  21. Creating a simple Java Servlet (Web Server Page) with Apache Maven on Microsoft Windows
    7,164
  22. Java Servlet Example
    7,115
  23. Difference between Java and Javascript
    7,605
  24. Challenge: One Code Problem Per Day
    1,093
  1. Java Polymorphism
    7,052
  2. Java Inheritance (Subclass and Superclass)
    7,178
  3. Java Packages
    7,174
  4. Java Abstract Classes and Methods
    7,723
  5. Java Classes and Objects
    7,078
  6. Java Recursion
    7,197
  7. Java Scope
    7,089
  8. Java Methods
    7,081
  9. Java Arrays
    8,691
  10. Java While Loop/Do While Loop/For Loop/For-Each Loop/Break/Continue
    7,847
  11. Java Switch Statements
    7,402
  12. Java Short Hand If...Else (Ternary Operator)
    7,572
  13. Java If ... Else
    7,392
  14. Java Math
    7,429
  15. Java Variables
    7,461
  16. The Print() Method
    7,148
  17. Java Syntax
    7,436
  18. Java Getting Started
    7,406
  19. What is Java?
    7,088
Recently updated
  1. Watch This Dazzling Dancer’s Mind-Blowing Moves
    51
  2. Michael Jackson's Billie Jean
    131
  3. Bootstrap vs. Tailwind CSS: Origins, Features, Pros & Cons, and How to Choose the Right Framework
    139
  4. The Complete Guide to Golang: History, Features, Real-World Uses, and Code Examples
    418
  5. Telemetry vs. Analytics: Understanding the Difference and Why It Matters
    238
  6. The Evolution and Production Reality of Agentic AI
    214
  7. How to Activate or Waive Your UIUC Student Health Insurance
    297
  8. Complete Guide to Building a Machine Learning Model
    325
  9. My life cuts at Las Vegas during Thanksgiving day holiday
    7,407
  10. The Cybercab Transformation: From Autonomous Taxi to Mobile Base Station
    354
  11. Harness vs. OpenClaw: Two Very Different "Agents"
    980
  12. Clean Python Environments: The Power of venv vs. Docker
    826
  13. What is Docker? Why is Docker also useful in a development environment?
    621
  14. UIUC 2026-2027 Academic Calendar
    1,597
  15. How to Build Llama 3 AI Apps with Python: Setup & User Prompts
    810
  16. Open-Source LLMs: The AI Revolution
    762
  17. Resume 2.0: Leveling Up for My First Software Gig
    2,229
  18. Not everyone will understand what this man just did
    1,888
  19. UIUC Dorm Guide: Find Your Perfect Fit !!
    1,596
  20. Unpacking IU's Shopper
    769
  21. Jackie Chan's Police Story: The Action Masterpiece
    664
  22. The IVE Story: Identity, 'I AM' Charts, and Influence
    968
  23. Tech Visionaries who graduated at UIUC - You are the Next Turn
    1,187
  24. Open Databases for Sex Crime Occurrences in the U.S.
    718
  25. Automatically copy text to the clipboard when dragging the mouse in the Cursor
    2,653
  26. My First Day at University of Illinois-Urvana Champaign
    1,197
  27. Sand, Sea, and a Splash of Fun at Newport Beach: A Family Adventure
    8,134
  28. Sun, Rocks, and Adventure: A Day at Joshua Tree National Park
    8,216
  29. Sipping the Stars: My Starbucks Adventure
    9,660
  30. Exciting explore at Sequoia National Park
    7,664
  31. My Life Shot at Death Valley
    1,713
  32. Ip Man fights with Muay Thai Master
    944
  33. Mad Clown - Don't Die
    1,027
  34. How to get Student Enrollment and Degree Verification at UIUC
    4,906
  35. LAX Thanksgiving Rush: A Joyful Reunion
    925
  36. ZO ZAZZ(조째즈) - Don`t you know (모르시나요) (PROD.ROCOBERRY)
    1,131
  37. FISHINGIRLS Unleashes Energetic EP 'Funiverse' Featuring Signature Track 'Fishing King'
    987
  38. 10CM - To Reach You (너에게 닿기를)
    1,165
  39. Feeling weak? Transform yourself at the UIUC ARC!
    1,573
  40. BOYNEXTDOOR - If I Say I Love You
    1,188
  41. The Future of Software Engineer - AI Engineering
    932
  42. G Dragon x Taeyang (Eyes Nose Lips, Power, Home Sweet Home, GOOD BOY) - LE GALA PIÈCES JAUNES 2025
    920
  43. Lie - Legend song by BIGBANG
    7,820
  44. Why ROLLBACK is useful when you work with Google Gemini CLI?
    844
  45. Reimbursement after Vaccination at McKinley Health Center
    1,023
  46. Gemini CLI makes a Magic! Time to speed up your app development with Google Gemini CLI!
    968
  47. Common Questions from UIUC school life in terms of CS Program
    1,125
  48. UIUC Immunization Compliance
    1,213
  49. LEE CHANHYUK's songs really resonate with my soul - Time Stop! Vivid LaLa Love, Eve, Endangered Love ...
    1,099
  50. LEE CHANHYUK - Endangered Love (멸종위기사랑)
    1,096