2
votes
3answers
335 views

Else statement inside Switch is an syntax error?

I am getting Syntax Error on the else statement in the following code : switch(v.getId()) { case R.id.b0 : if(s.length()==1 && s.charAt(0)=='0'); { et2.setText("0"); ...
0
votes
4answers
67 views

Switch statement or an if else statement? [closed]

I'm currently learning Javascript through Codecadamy, and they've just introduced a switch statement. However, I'm at a loss. Why use an if else statement if you can just use a switch statement? It ...
0
votes
5answers
68 views

Differences between IF and SWITCH/CASE in C

The question is really simple: in a laboratory class I attended this year, professor presented the switch/case statement alongside the classic if/then/else statement without saying anything about ...
3
votes
4answers
126 views

How do I do a switch case for jQuery?

I have this if-else statement which gave me weird response... whenever i select "output" first, nothing else selected afterwards can appear... FYI, I am using multi select so I can select and show as ...
6
votes
2answers
8k views

How to detect window size and then do something with jquery switch statement

i would like to check for the window size with jquery and based on the different resolutions i would like to change the background image. So i was thinking to somehow use the "switch" statement for ...
4
votes
2answers
49 views

Why is if-else for String faster than switch-case for enum?

As Java 6 does not have switch-case for String, I often change an if-else block to switch-case using enum as in the code below. However, when I tried to check the performance of the two alternatives, ...
22
votes
9answers
2k views

How to reduce if statements [closed]

The program below functions as necessary but how do I reduce the amount of if statements. I have been told that if your function contains 2 or more if statements then your doing it wrong. Any ...
0
votes
1answer
37 views

Passing a value from one case to another in switch statement

So here is a sample code : import java.util.Scanner; public class Test { public static void main(String[] args) { System.out.println("Please type in a number"); Scanner in = new ...
0
votes
1answer
37 views

Accessing a returned value from a different case

Hi It's the 3rd time i'm posting this question on this forum and up to now no one has been capable to enlighten me about this situation. I only pasted the code that matters here and will try to ...
0
votes
4answers
89 views

Choose of a lot of cases instead of c >= '0' && c <= '9' to 0-9 numbers checking

The following code is part of an intepreter that I'm reading. I'm trying to figure why exactly use this instead of simple c >= '0' && c <= '9'? switch(ch) { //... case '0': case ...
1
vote
0answers
17 views

how can i count the working days of an employee generating 1 2..31 days and the time will only appear to those days using vb.net

Dim cmd As OdbcCommand = New OdbcCommand("SELECT distinct checktime,format(CHECKTIME,'Short Date') as adlaws, format(CHECKTIME,'ampm') as formatz,checktype " & _ ...
-5
votes
3answers
80 views

Preventing If within If functions (or cases)

I'm building a code where I have to go trough alot of if/case functions. This on itself is not really a problem only that alot of these if's are the kinda the same. In my code it has to go trough an ...
-1
votes
4answers
38 views

Register form Error Correction in PHP - Best solution?

I'm looking for as simple approach to correcting errors such as non-matching passwords and people inserting blank data into a form in HTML. I want to use PHP to throw me back an error when this ...
53
votes
22answers
24k views

Advantage of switch over if-else statement

What's the best practice for switch vs if for a 30 unsigned enumerations where about 10 have an expected action (that presently is the same action). Performance and space need to be considered but ...

1 2 3 4 5 12
15 30 50 per page