Looping Statement vs Switch Statement


#1

In Looping Statement(For Each / While) and Switch statement, Which activity has high performance and reduce processing time ?


#2

Hello,

Looping Statements: For each and while traverse/iterate an each elements which are contained in array of elements.
Switch Statement: Case statements are used to set different conditions. The break statement is used to break from the entire switch statement, once a condition is true.

Cheers,
Pankaj


#3

See this for Switch -

and for loops -


#4

My question is Which activity reduces process timing and improve performance during execution ??


#5

Both activities have different execution method and different results of implementation. You can compare If Statement and Switch statement or you can compare for each loop with While or Do while. There is no point of comparing Switch to Loops


#6

My scenario is “I have 10 records are 20 application, i have classified the records for each applications. Now, 10 records are missing for another 10 applications.”

I have to access only the 10 application for that 10 records , where i dont have records for other application.

Now, should i go with looping for all application or should i go with switch by if statement to go directly to the specfic app for the particular record?"


#7

If you are sure that application would be 10 only and this number would not increase you should try Switch for any ifs and buts you should use loop