Java Comments
There are three types of comments in Java
1. Single Line comment
To comment on a single line of code, you can use a double forward slash “//” followed by your message. This syntax is commonly used for coding.
Java
/*package whatever //do not write package name here */ import java.io.*; class GFG { public static void main(String[] args) { System.out.println( "GFG!" ); // System.out.println("Thi line is not executed"); } } |
GFG!
2. Multi-line comment
If you need to comment on multiple lines of code, you can utilize the syntax of a double forward slash “/*”. Simply enter your message between the two symbols, and complete the comment with “*/”. This is a widely used syntax in coding.
Java
/*package whatever //do not write package name here */ import java.io.*; class GFG { public static void main(String[] args) { System.out.println( "GFG!" ); /* System.out.println("This line is Ignored ny comiler"); System.out.prinln("Including this"); */ } } |
GFG!
3. JavaDoc Type Comment
When working on a project or software package, it is often helpful to use this method as it can assist in creating a documentation page for reference. This page can provide information on available methods, their parameters, and more, making it a useful tool for learning about the project.
Syntax:
/** Comment starts
*This is
*sample comment */
Java Cheat Sheet
Java is a programming language and platform that has been widely used since its development by James Gosling in 1982. It follows the Object-oriented Programming concept and can run programs written in any programming language. Java is a high-level, object-oriented, secure, robust, platform-independent, multithreaded, and portable programming language All those words are collectively called Java Buzzwords. It is commonly used for programming web-based, window, enterprise, and mobile applications. This Java Cheat Sheet article has been written by experts in Java and based on the experience of students who have recently undergone Java interviews.
This Core Java Cheat Sheet has been designed by Java experts, based on the experience of students who have recently undergone Java interviews. Whether you are a beginner or an experienced Java developer, this Java Cheat Sheet is a valuable resource for quickly accessing essential syntax, concepts, and best practices related to Java Programming.