The if statement is used to select among two alternatives. It uses a boolean expression todecide whichalternative should be executed. The switch statement is used to select among multiplealternatives. It usesan int expression to determine which alternative should be executed. Source: CoolInterview.com
"if" statement can be used to compare about objects. for example: String compare to String. But for "switch" statement, it can only compare about int, byte,char, long, short, and enum Source: CoolInterview.com
In if statement we can use relation operator such as(<,>,<=,>=) and also use boolean. Here in if statement if we use nested if statement then the first condition is false then they go to next 'else-if' . But in switch we can we can just the value and direclty go to that 'case'.
In Java, You can create a String object as: String str = "abc"; & String str = new String("abc"); Why cant a button object be created as : Button bt = "abc" Why is it compulsory to create a button object as: Button bt = new Button("abc"); Why is this not compulsory in String's case?