diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..6f3a291 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "liveServer.settings.port": 5501 +} \ No newline at end of file diff --git a/java/basics/comments.md b/java/basics/comments.md new file mode 100644 index 0000000..a57ad66 --- /dev/null +++ b/java/basics/comments.md @@ -0,0 +1,110 @@ + Comments are like indents one makes, they are used so that it is easier for someone who isn’t familiar with the language to be able to understand the code. It will also make the job easier for you, as a coder, to find errors in the code since you will be easily able to find the location of the bug. Comments are ignored by the compiler while compiling a code, which makes the job more complex in the long run when they have to go through so much code to find one line. + +In Java there are three types of comments: + + Single-line comments. + Multi-line comments. + Documentation comments. + +A. Single-line comments + A beginner-level programmer uses mostly single-line comments for describing the code functionality. It’s the easiest typed comments. + + Syntax: //Comments here( Text in this line only is considered as comment ) + + Example: + + + // Java program to show single line comments + + class Scomment + { + public static void main(String args[]) + { + // Single line comment here + System.out.println("Single line comment above"); + } + } + +B. Multi-line Comments: + To describe a full method in a code or a complex snippet single line comments can be tedious to write since we have to give ‘//’ at every line. So to overcome this multi-line comments can be used. + + Syntax: + + /*Comment starts + continues + continues + . + . + . + Comment ends*/ + Example: + + + //Java program to show multi line comments + class Scomment + { + public static void main(String args[]) + { + System.out.println("Multi line comments below"); + /*Comment line 1 + Comment line 2 + Comment line 3*/ + } + } +C. Documentation Comments: + This type of comment is used generally when writing code for a project/software package, since it helps to generate a documentation page for reference, which can be used for getting information about methods present, its parameters, etc. For example, http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html is an auto-generated documentation page that is generated by using documentation comments and a javadoc tool for processing the comments. + + Syntax: + + /**Comment start + * + *tags are used in order to specify a parameter + *or method or heading + *HTML tags can also be used + *such as