Advertisement
vinedfs

Exemplo de Switch

Jun 26th, 2014
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. package br.com.geracao.base.main;
  2.  
  3. public class MainApplication {
  4.    
  5.     public static void main(String[] args) {
  6.        
  7.         int cargo = 1;
  8.        
  9.         switch (cargo) {
  10.             case 1:
  11.                 System.out.println("Olá diretor!");
  12.                 break;
  13.             case 2:
  14.                 System.out.println("Olá contador!");
  15.                 break;
  16.             case 3:
  17.                 System.out.println("Olá carteiro!");
  18.                 break;
  19.             default:
  20.                 System.out.println("Essa profissão não foi cadastrada.");
  21.         }
  22.        
  23.     }
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement