Java programming-Operators

Add to Favourites
Post to:

Description
Aprogramming language uses control statements to cause the flow of execution
to advance and branch based on changes to the state of a program. Java’s program
control statements can be put into the following categories: selection, iteration,
and jump. Selection statements allow your program to choose different paths of execution
based upon the outcome of an expression or the state of a variable. Iteration statements
enable program execution to repeat one or more statements (that is, iteration statements
form loops). Jump statements allow your program to execute in a nonlinear fashion. All
of Java’s control statements are examined here.
If you know C/C++/C#, then Java’s control statements will be familiar territory. In fact,
Java’s control statements are nearly identical to those in those languages. However,
there are a few differences—especially in the break and continue statements.

Comments
Presentation Transcript Presentation Transcript

Java ProgrammingControl Structures : Java ProgrammingControl Structures By Adepu Ravi Krishna

Selection Statements : Selection Statements if statement ex) if (A>B) { System.out.println(“A>B”); } if…else statement ex) if (A>B) { System.out.println(“A>B”); } else { System.out.println(“A<=B”); } switch Statement ex) switch (A) { case 1: { System.out.println(“A=1”); break; } case 2: { System.out.println(“A=2”); break; } … default: { System.out.println(“A Undefined”); } }

Repetitions(while, do while, and for) : Repetitions(while, do while, and for) An example adding all numbers between 1 to 100 Using While: // Variable Declaration & Initialization int sum = 0; int count = 0; // Processing while (count <= 1000) { sum = sum + count; count = count +1; //same as count++ } // Output System.out.println(“Sum: “ + sum);

Repetitions(while, do while, and for) : Repetitions(while, do while, and for) Using do-while: // Variable Declaration & Initialization int sum =0; int count =0; // Processing do { sum = sum + count; count = count +1; //same as count++ } while (count <=1000); Using for: // Variable Declaration & Initialization int sum =0; // Processing for (int count =0; count <= 100; count++) { sum = sum +count; }

Want to learn?

Sign up and browse through relevant courses.

Name:
Your Email:
Password:
Country:
Contact no:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy
ravikrishna adepu
Fresher Java Programmer
User
6 Members Recommend
26 Followers

Your Facebook Friends on WizIQ

Give live classes, create & sell online courses

Try it free Plans & Pricing

Connect