The Java continue statement is used to continue loop. It continues the current flow of the program and skips the remaining code at specified condition.
continue keyword in innerloop
Program
publicclass continue_inner
{
publicstaticvoid main(String args[])
{
for(int i=1; i<=5; i++)
{
for(int j=1; j<=5; j++)
{
if(i==3 && j==3)
{
continue;
}
System.out.println(i + "-" + j);
}
}
}
}
Output
1-1
1-2
1-3
1-4
1-5
2-1
2-2
2-3
2-4
2-5
3-1
3-2
3-4
3-5
4-1
4-2
4-3
4-4
4-5
5-1
5-2
5-3
5-4
5-5
Explanation
It continues inner loop only if you use continue statement inside the inner loop.
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 ...
While loop in JAVA Syntax while (condition){ //code to be executed } Program public class while_loop { public static void main( String args[]) { int i = 1 ; while (i <= 10 ) { System.out.println(i); i++; } } } Run Output 1 2 3 4 5 6 7 8 9 10 Explanation The Java while loop is used to iterate a part of the program several times. If the number of iteration is not fixed, it is recommended to use while loop. While loop starts with the checking of condition. If it evaluated to true, then the loop body statements are executed otherwise first statement following the loop is executed. For this reason it is also called Entry control loop. Once the condition is evaluated to true, the statements in the loop body are executed. Normally the statements contain an update value for the variable being processed for the next iteration. When...
Comments
Post a Comment