Switch-case is used by devolopers for defining to computer conditional statements. Switch-case expressions have same functions with if blocks.Using of switch case use less common than if blocks wherefore if blocks are more useful in projects of software. Structere of Switch-case; switch( parameter){ case x: ......// if parater is x, these codes are run that untill break expression.Does not run any other statement break's below. break; case a: ......// if parater is a, these codes are run that untill break expression.Does not run any other statement break's below. break; } public class Main { public static void main ( String [] args) { int BestTeam = 6 ; switch ( BestTeam ){ case 1 : System . out .println( "Best Team in Spain is Barcelona" ); break ; case 2 : System . out .println( "Best Team in İtaly is Juventus" ); break ; case 3 : ...
İf a person who coding in java must define to computer what want doing to computer for the some conditionals. Blocks: İf: İf blocks are used for statements if it the condition is true if block is run on the java compiler. else: İf "if" block is not true ,"else" block is run on the java compiler, else if:"Else" if is used for other diffrent conditionals than based if. public class Main { public static void main ( String [] args) { int a = 4 ; int c = 6 ; if ( a * c > 25 ){ System . out .println( "Contition is true" ); } else { System . out .println( "condition is false" ); } } } OUTPUT: condition is false