Advertisement
Guest User

Switch-case exemplo

a guest
Oct 20th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. package aula;
  2.  
  3. public class TesteSwitch {
  4.     public static void main(String[] args) {
  5.         char resp = 'S';
  6.         System.out.println(AnalizarResposta(resp));
  7.     }
  8.     public static boolean AnalizarResposta(char resposta) {
  9.         switch(resposta) {
  10.         case 's':
  11.         case 'S': return true;
  12.         case 'n':
  13.         case 'N': return false;
  14.         default:
  15.             System.out.println("Resposta inválida!");
  16.             return false;
  17.         }
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement