The java comments are statements that are not executed by the compiler and interpreter. The comments can be used to provide information or explanation about the variable, method, class or any statement. It can also be used to hide program code for specific time.
Three types of comment in Java
1. Single line comment
Syntax
// This is single line comment
// This line won't be executed
Program
publicclass SingleLineComment
{
publicstaticvoid main(String args[])
{
// break keyword example
for(int i=1; i<=10; i++)
{
if(i==6)
{
break;
}
System.out.println(i);
}
}
}
Output
1
2
3
4
5
2. Multi line comment
Syntax
/* This is multi
line commment
This line won't
be executed */
Program
publicclass MultiLineComment
{
publicstaticvoid main(String args[])
{
for(int i=1; i<=10; i++)
{
/* Exmple of
break
keyword */
if(i==6)
{
break;
}
System.out.println(i);
}
}
}
Output
1
2
3
4
5
3. Documentation comment
Syntax
/** This is
documentation
comment */
Program
publicclass DocComment
{
publicstaticvoid main(String args[])
{
}
/** The add() method returns addition of given numbers.*/
publicstaticint add(int a, int b)
{
return a+b;
}
/** The div() method returns divison of given numbers.*/
publicstaticint div(int a, int b)
{
return a/b;
}
}
Output
javac DocComment.java
javadoc DocComment.java
Explanation
The documentation comment is used to create documentation API. To create documentation API, you need to use javadoc tool.
Now, there will be HTML files created for your Calculator class in the current directory. Open the HTML files and see the explanation of Calculator class provided through documentation comment.
In this article we view three key (and interrelated) topics that make it all possible: the CLR, CTS, and CLS . Common Language Runtime From a programmer’s point of view, .NET can be understood as a runtime environment and a comprehensive base class library. The runtime layer is properly referred to as the Common Language Runtime , or CLR. The primary role of the CLR is to locate, load, and manage .NET objects on your behalf. The CLR also takes care of a number of low-level details such as memory management, application hosting, coordinating threads, and performing basic security checks (among other low-level details). Common Type System Another building block of the .NET platform is the Common Type System , or CTS. The CTS specification fully describes all possible data types and all programming constructs supported by the runtime, specifies how these entities can interact with each other, and details how they are represented in the .NET metadata format. Common Languag...
With the first introduction post of C# you can understand the return value of the Main() method, let’s examine the incoming array of string data. Assume that you now want to update your application to process any possible command-line parameters. One way to do so is using a C# for loop. We will see for loop in C# in later article. Accessing command line arguments with for loop Program using System; public class CLA { public static void Main(string[] args) { //this loop prints any number of given command line arguments for(int i=0; i<args.Length; i++) { Console.WriteLine("arg-" + i + " = " + args[i]); } } } Output F:\Code\Algorithm>csc CLA.cs F:\Code\Algorithm>CLA tangled java elaborately arg-0 = tangled arg-1 = java arg-2 = elaborately Explanation Here, you are checking to see whether the array of strings contains some number of items using the Length property of Sys...
Like any programming language, C# defines keywords for fundamental data types, which are used to represent local variables, class data member variables, method return values, and parameters. Unlike other programming languages, however, these keywords are much more than simple compiler- recognized tokens. Rather, the C# data type keywords are actually shorthand notations for full-blown types in the System namespace. Table lists each system data type, its range, the corresponding C# keyword, and the type’s compliance with the common language specification (CLS). C# keyword System type Range Meaning CLS complaint? bool System.Boolean true or false Represents truth or falsity Yes sbyte System.SByte -128 to 127 signed 8-bit number No byte System.Byte 0 to 255 Unsigned 8-bit ...
Comments
Post a Comment