Search This Blog

If you like any posts in this blog then click this icon which is present under the post

Thursday 11 August 2011

Labelled Loops


                Java has a facility to give labels to a block of statements.
The general form is

label : Looping statement

Where,
                label                            -  valid java variable name
                looping statement – for,do,while

Continue statement - skipping a part of a loop


               Continue statement is used to skip a part in the body of the loop. When this statement is used inside a loop it skips the execution of the remaining statements in the body of the loop after the keyword continue and continue with the next iteration.

The general form is

continue;

                When this statement is used inside a for loop the control is transferred to the beginning of the loop. If it is used inside while or do loops the control is transferred to the test condition.

Break Statement - Jumping out of a loop


                Break statement is used to exit from a loop while the test condition is true. This statement can be used within a for, while, do-while or switch statement.

The general form is
                                               
break;

                When the break statement is executed inside a loop, the execution of the loop is terminated and the program continues with the statement following the loop. If break statement is used in nested loops, it will exit from the loop containing it.

Program for Parity bit Generator and Checker using TCP/IP


Client
import java.io.*;
import java.net.*;
import java.util.*;
class Clientparity
{          public static void main(String args[])
            {
            try       
            {         
                        BufferedReader in=new BufferedReader(new InputStreamReader(System.in));
                        Socket clsct=new Socket("127.0.0.1",139);
                        DataInputStream din=new DataInputStream(clsct.getInputStream());
                        DataOutputStream dout=new DataOutputStream(clsct.getOutputStream());

Followers