Skip to main content

Switch - Case in Java

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:
System.out.println("Best Team in England is Liverpool");
break;
case 4:
System.out.println("Best Team in France is PSG");
break;
case 5:
System.out.println("Best team in Netharlands is Ajax");
break;
case 6:
System.out.println("Best Team in Turkey is Trabzonspor");
break;
default:
System.out.println("please choose number for 1-6");

}
}
}
OUTPUT:
Best Team in Turkey is Trabzonspor









Comments

Popular posts from this blog

First Java Code Say : "Hello World" !

Person who wants to learn software is meeting with writing to computer screen "Hello World". That's why our first topic is writing to output from computer "Hello World" with java code. Method of "System.out.println" is used in Java to output from computer. public class Main { public static void main ( String [] args) { System . out .println( "Hello World" ); } } Output : Hello World Dont think about any matters such as "public static void main".I will be describe every method which you see as soon as posibble at next topics.

WHY WE LEARN JAVA

Java is a programming language which people use for devoloping projects. Java has crucial position on the software sector.  Person who knows Java is able to develope mobile and desktop applications, and can getting a job the projects of corporete to software companies. You are going to find ways how well-being writing Java projects clearly with sustainable-way at the this site.

Variables in Java

Java is  a safe-type programming language  so person who coding in Java need to indicate object's type.  İf i must explain little more, just think about "4" or thinking about "Love" how can you say to computer that which one of  number or   string. That's why, variables are used in java. Variables: String: String is used to desribe characters more than one. char:char is used to descrice a character. int: int is used to describe integers. float and double: These variabeles are used to describe    decimal numbers. boolean : boolean returns "0" or 1" . byte: byte is used describe 8 byte integers. long: longe s used  describe 64 byte integers. short: short is used describes 16 byte integers. public class Main { public static void main ( String [] args) { String a = "LOVE" ; int b = 4 ; long c = 1521468348 ; char d = 'e' ; short f = 4574 ; double p = 4.22145 ; System . out .println( a ); System. out .println( b...