Posts

Showing posts with the label comment best practices

Comments in Java

Next Comments in Java Comments in any programming language are ignored by the compiler or the interpeter. The programmer uses it to either explain a block of code or to avoid the execution of a specific part of the code while testing. There are two types of comments: Single-line comment Multi-line comment Single/In-line comment To write a single-line comment just add a ‘//’ at the start of the line. Example public class Main { public static void main ( String [ ] args ) { //This is a single line comment System . out . println ( "Hello learnwithvaigandla" ) ; } } Output Hello learnwithvaigandla Multi-line comment To write a multi-line comment just add a ‘/*…….*/’ at the start of the line. Exa...