Question

Is it possible to create a new "Custom Conditional Statement" in java.

Here i am planning to create a new custom component for the switch statement to give better performance. The custom Switch control which i am planning to create will have only integer operators: example:

int i = SOMEVALUE;
Switch(i)
{
Case 1: 
//Some Statement
Break;
Case 2: 
//Some Statement
Break;
Case 3: 
//Some Statement
Break;
....
....
....
Case 10000000: 
//Some Statement
Break;
Default:
//Some Statement
Break;
}

According to my knowledge the Switch condition will check in a particular order. If the actual value of the "i" variable is 9999999 then it has to check the case for 9999999 times but if we check it with some algorithms similar to binary search then its performance will be improved. Am I Right ??

If right then why don't we add this functionality to our programming language ? So why don't we create a "Custom Conditional Statement" something like "OrderedIntegerSwitch statement" , in which the value passed inside that switch should be an integer.

No correct solution

Licensed under: CC-BY-SA with attribution
scroll top