SlideShare uma empresa Scribd logo
1 de 15
Baixar para ler offline
53 Curso de Java
Enumeradores
(Enum)
Constantes no Java
public class DiaSemanaConstantes {
public static final int SEGUNDA = 1;
public static final int TERCA = 2;
public static final int QUARTA = 3;
public static final int QUINTA = 4;
public static final int SEXTA = 5;
public static final int SABADO = 6;
public static final int DOMINGO = 7;
}
int segunda = DiaSemanaConstantes.SEGUNDA;
int terca = DiaSemanaConstantes.TERCA;
int quarta = DiaSemanaConstantes.QUARTA;
int quinta = DiaSemanaConstantes.QUINTA;
int sexta = DiaSemanaConstantes.SEXTA;
int sabado = DiaSemanaConstantes.SABADO;
int domingo = DiaSemanaConstantes.DOMINGO;
System.out.println("Usando constantes");
imprimeDiaSemana(segunda);
imprimeDiaSemana(terca);
imprimeDiaSemana(quarta);
imprimeDiaSemana(quinta);
imprimeDiaSemana(sexta);
imprimeDiaSemana(sabado);
imprimeDiaSemana(domingo);
private static void imprimeDiaSemana(int dia){
switch (dia) {
case 1:
System.out.println("Segunda-feira");
break;
case 2:
System.out.println("Terça-feira");
break;
case 3:
System.out.println("Quarta-feira");
break;
case 4:
System.out.println("Quinta-feira");
break;
case 5:
System.out.println("Sexta-feira");
break;
case 6:
System.out.println("Sábado");
break;
case 7:
System.out.println("Domingo");
break;
}
}
Enum no Java
public enum DiaSemana {
SEGUNDA, TERCA, QUARTA, QUINTA, SEXTA, SABADO, DOMINGO;
}
DiaSemana segunda = DiaSemana.SEGUNDA;
DiaSemana terca = DiaSemana.TERCA;
DiaSemana quarta = DiaSemana.QUARTA;
DiaSemana quinta = DiaSemana.QUINTA;
DiaSemana sexta = DiaSemana.SEXTA;
DiaSemana sabado = DiaSemana.SABADO;
DiaSemana domingo = DiaSemana.DOMINGO;
System.out.println("Usando enum");
imprimeDiaSemana(segunda);
imprimeDiaSemana(terca);
imprimeDiaSemana(quarta);
imprimeDiaSemana(quinta);
imprimeDiaSemana(sexta);
imprimeDiaSemana(sabado);
imprimeDiaSemana(domingo);
private static void imprimeDiaSemana(DiaSemana dia){
switch (dia) {
case SEGUNDA:
System.out.println("Segunda-feira");
break;
case TERCA:
System.out.println("Terça-feira");
break;
case QUARTA:
System.out.println("Quarta-feira");
break;
case QUINTA:
System.out.println("Quinta-feira");
break;
case SEXTA:
System.out.println("Sexta-feira");
break;
case SABADO:
System.out.println("Sábado");
break;
case DOMINGO:
System.out.println("Domingo");
break;
}
}
Hands On!
https://github.com/loiane/curso-java-basico
Código Fonte:
Não conhece Git/Github?
http://www.loiane.com/2013/11/
screencast-git-e-github-para-iniciantes
http://loiane.training
Fórum para dúvidas + certificado do curso.
Cadastro em:
http://loiane.com
facebook.com/loianegroner
@loiane
https://github.com/loiane
youtube.com/user/Loianeg
Obrigada!
http://loiane.com

Mais conteúdo relacionado

Último

Transformações isométricas.pptx Geometria
Transformações isométricas.pptx GeometriaTransformações isométricas.pptx Geometria
Transformações isométricas.pptx Geometriajucelio7
 
Dicionário de Genealogia, autor Gilber Rubim Rangel
Dicionário de Genealogia, autor Gilber Rubim RangelDicionário de Genealogia, autor Gilber Rubim Rangel
Dicionário de Genealogia, autor Gilber Rubim RangelGilber Rubim Rangel
 
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...azulassessoria9
 
Mapa mental - Classificação dos seres vivos .docx
Mapa mental - Classificação dos seres vivos .docxMapa mental - Classificação dos seres vivos .docx
Mapa mental - Classificação dos seres vivos .docxBeatrizLittig1
 
Pedologia- Geografia - Geologia - aula_01.pptx
Pedologia- Geografia - Geologia - aula_01.pptxPedologia- Geografia - Geologia - aula_01.pptx
Pedologia- Geografia - Geologia - aula_01.pptxleandropereira983288
 
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...azulassessoria9
 
CRUZADINHA - Leitura e escrita dos números
CRUZADINHA   -   Leitura e escrita dos números CRUZADINHA   -   Leitura e escrita dos números
CRUZADINHA - Leitura e escrita dos números Mary Alvarenga
 
Slide língua portuguesa português 8 ano.pptx
Slide língua portuguesa português 8 ano.pptxSlide língua portuguesa português 8 ano.pptx
Slide língua portuguesa português 8 ano.pptxssuserf54fa01
 
Slides Lição 04, Central Gospel, O Tribunal De Cristo, 1Tr24.pptx
Slides Lição 04, Central Gospel, O Tribunal De Cristo, 1Tr24.pptxSlides Lição 04, Central Gospel, O Tribunal De Cristo, 1Tr24.pptx
Slides Lição 04, Central Gospel, O Tribunal De Cristo, 1Tr24.pptxLuizHenriquedeAlmeid6
 
Descreve o conceito de função, objetos, imagens, domínio e contradomínio.
Descreve o conceito de função, objetos, imagens, domínio e contradomínio.Descreve o conceito de função, objetos, imagens, domínio e contradomínio.
Descreve o conceito de função, objetos, imagens, domínio e contradomínio.Vitor Mineiro
 
Grupo Tribalhista - Música Velha Infância (cruzadinha e caça palavras)
Grupo Tribalhista - Música Velha Infância (cruzadinha e caça palavras)Grupo Tribalhista - Música Velha Infância (cruzadinha e caça palavras)
Grupo Tribalhista - Música Velha Infância (cruzadinha e caça palavras)Mary Alvarenga
 
GÊNERO TEXTUAL - TIRINHAS - Charges - Cartum
GÊNERO TEXTUAL - TIRINHAS - Charges - CartumGÊNERO TEXTUAL - TIRINHAS - Charges - Cartum
GÊNERO TEXTUAL - TIRINHAS - Charges - CartumAugusto Costa
 
o ciclo do contato Jorge Ponciano Ribeiro.pdf
o ciclo do contato Jorge Ponciano Ribeiro.pdfo ciclo do contato Jorge Ponciano Ribeiro.pdf
o ciclo do contato Jorge Ponciano Ribeiro.pdfCamillaBrito19
 
A poesia - Definições e Característicass
A poesia - Definições e CaracterísticassA poesia - Definições e Característicass
A poesia - Definições e CaracterísticassAugusto Costa
 
Construção (C)erta - Nós Propomos! Sertã
Construção (C)erta - Nós Propomos! SertãConstrução (C)erta - Nós Propomos! Sertã
Construção (C)erta - Nós Propomos! SertãIlda Bicacro
 
AD2 DIDÁTICA.KARINEROZA.SHAYANNE.BINC.ROBERTA.pptx
AD2 DIDÁTICA.KARINEROZA.SHAYANNE.BINC.ROBERTA.pptxAD2 DIDÁTICA.KARINEROZA.SHAYANNE.BINC.ROBERTA.pptx
AD2 DIDÁTICA.KARINEROZA.SHAYANNE.BINC.ROBERTA.pptxkarinedarozabatista
 
"É melhor praticar para a nota" - Como avaliar comportamentos em contextos de...
"É melhor praticar para a nota" - Como avaliar comportamentos em contextos de..."É melhor praticar para a nota" - Como avaliar comportamentos em contextos de...
"É melhor praticar para a nota" - Como avaliar comportamentos em contextos de...Rosalina Simão Nunes
 
11oC_-_Mural_de_Portugues_4m35.pptxTrabalho do Ensino Profissional turma do 1...
11oC_-_Mural_de_Portugues_4m35.pptxTrabalho do Ensino Profissional turma do 1...11oC_-_Mural_de_Portugues_4m35.pptxTrabalho do Ensino Profissional turma do 1...
11oC_-_Mural_de_Portugues_4m35.pptxTrabalho do Ensino Profissional turma do 1...licinioBorges
 
Slides Lição 5, CPAD, Os Inimigos do Cristão, 2Tr24, Pr Henrique.pptx
Slides Lição 5, CPAD, Os Inimigos do Cristão, 2Tr24, Pr Henrique.pptxSlides Lição 5, CPAD, Os Inimigos do Cristão, 2Tr24, Pr Henrique.pptx
Slides Lição 5, CPAD, Os Inimigos do Cristão, 2Tr24, Pr Henrique.pptxLuizHenriquedeAlmeid6
 

Último (20)

Transformações isométricas.pptx Geometria
Transformações isométricas.pptx GeometriaTransformações isométricas.pptx Geometria
Transformações isométricas.pptx Geometria
 
Dicionário de Genealogia, autor Gilber Rubim Rangel
Dicionário de Genealogia, autor Gilber Rubim RangelDicionário de Genealogia, autor Gilber Rubim Rangel
Dicionário de Genealogia, autor Gilber Rubim Rangel
 
CINEMATICA DE LOS MATERIALES Y PARTICULA
CINEMATICA DE LOS MATERIALES Y PARTICULACINEMATICA DE LOS MATERIALES Y PARTICULA
CINEMATICA DE LOS MATERIALES Y PARTICULA
 
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
 
Mapa mental - Classificação dos seres vivos .docx
Mapa mental - Classificação dos seres vivos .docxMapa mental - Classificação dos seres vivos .docx
Mapa mental - Classificação dos seres vivos .docx
 
Pedologia- Geografia - Geologia - aula_01.pptx
Pedologia- Geografia - Geologia - aula_01.pptxPedologia- Geografia - Geologia - aula_01.pptx
Pedologia- Geografia - Geologia - aula_01.pptx
 
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
PROVA - ESTUDO CONTEMPORÂNEO E TRANSVERSAL: LEITURA DE IMAGENS, GRÁFICOS E MA...
 
CRUZADINHA - Leitura e escrita dos números
CRUZADINHA   -   Leitura e escrita dos números CRUZADINHA   -   Leitura e escrita dos números
CRUZADINHA - Leitura e escrita dos números
 
Slide língua portuguesa português 8 ano.pptx
Slide língua portuguesa português 8 ano.pptxSlide língua portuguesa português 8 ano.pptx
Slide língua portuguesa português 8 ano.pptx
 
Slides Lição 04, Central Gospel, O Tribunal De Cristo, 1Tr24.pptx
Slides Lição 04, Central Gospel, O Tribunal De Cristo, 1Tr24.pptxSlides Lição 04, Central Gospel, O Tribunal De Cristo, 1Tr24.pptx
Slides Lição 04, Central Gospel, O Tribunal De Cristo, 1Tr24.pptx
 
Descreve o conceito de função, objetos, imagens, domínio e contradomínio.
Descreve o conceito de função, objetos, imagens, domínio e contradomínio.Descreve o conceito de função, objetos, imagens, domínio e contradomínio.
Descreve o conceito de função, objetos, imagens, domínio e contradomínio.
 
Grupo Tribalhista - Música Velha Infância (cruzadinha e caça palavras)
Grupo Tribalhista - Música Velha Infância (cruzadinha e caça palavras)Grupo Tribalhista - Música Velha Infância (cruzadinha e caça palavras)
Grupo Tribalhista - Música Velha Infância (cruzadinha e caça palavras)
 
GÊNERO TEXTUAL - TIRINHAS - Charges - Cartum
GÊNERO TEXTUAL - TIRINHAS - Charges - CartumGÊNERO TEXTUAL - TIRINHAS - Charges - Cartum
GÊNERO TEXTUAL - TIRINHAS - Charges - Cartum
 
o ciclo do contato Jorge Ponciano Ribeiro.pdf
o ciclo do contato Jorge Ponciano Ribeiro.pdfo ciclo do contato Jorge Ponciano Ribeiro.pdf
o ciclo do contato Jorge Ponciano Ribeiro.pdf
 
A poesia - Definições e Característicass
A poesia - Definições e CaracterísticassA poesia - Definições e Característicass
A poesia - Definições e Característicass
 
Construção (C)erta - Nós Propomos! Sertã
Construção (C)erta - Nós Propomos! SertãConstrução (C)erta - Nós Propomos! Sertã
Construção (C)erta - Nós Propomos! Sertã
 
AD2 DIDÁTICA.KARINEROZA.SHAYANNE.BINC.ROBERTA.pptx
AD2 DIDÁTICA.KARINEROZA.SHAYANNE.BINC.ROBERTA.pptxAD2 DIDÁTICA.KARINEROZA.SHAYANNE.BINC.ROBERTA.pptx
AD2 DIDÁTICA.KARINEROZA.SHAYANNE.BINC.ROBERTA.pptx
 
"É melhor praticar para a nota" - Como avaliar comportamentos em contextos de...
"É melhor praticar para a nota" - Como avaliar comportamentos em contextos de..."É melhor praticar para a nota" - Como avaliar comportamentos em contextos de...
"É melhor praticar para a nota" - Como avaliar comportamentos em contextos de...
 
11oC_-_Mural_de_Portugues_4m35.pptxTrabalho do Ensino Profissional turma do 1...
11oC_-_Mural_de_Portugues_4m35.pptxTrabalho do Ensino Profissional turma do 1...11oC_-_Mural_de_Portugues_4m35.pptxTrabalho do Ensino Profissional turma do 1...
11oC_-_Mural_de_Portugues_4m35.pptxTrabalho do Ensino Profissional turma do 1...
 
Slides Lição 5, CPAD, Os Inimigos do Cristão, 2Tr24, Pr Henrique.pptx
Slides Lição 5, CPAD, Os Inimigos do Cristão, 2Tr24, Pr Henrique.pptxSlides Lição 5, CPAD, Os Inimigos do Cristão, 2Tr24, Pr Henrique.pptx
Slides Lição 5, CPAD, Os Inimigos do Cristão, 2Tr24, Pr Henrique.pptx
 

Destaque

PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...DevGAMM Conference
 

Destaque (20)

Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
Ride the Storm: Navigating Through Unstable Periods / Katerina Rudko (Belka G...
 

Java enum e constantes

  • 1. 53 Curso de Java Enumeradores (Enum)
  • 3. public class DiaSemanaConstantes { public static final int SEGUNDA = 1; public static final int TERCA = 2; public static final int QUARTA = 3; public static final int QUINTA = 4; public static final int SEXTA = 5; public static final int SABADO = 6; public static final int DOMINGO = 7; }
  • 4. int segunda = DiaSemanaConstantes.SEGUNDA; int terca = DiaSemanaConstantes.TERCA; int quarta = DiaSemanaConstantes.QUARTA; int quinta = DiaSemanaConstantes.QUINTA; int sexta = DiaSemanaConstantes.SEXTA; int sabado = DiaSemanaConstantes.SABADO; int domingo = DiaSemanaConstantes.DOMINGO; System.out.println("Usando constantes"); imprimeDiaSemana(segunda); imprimeDiaSemana(terca); imprimeDiaSemana(quarta); imprimeDiaSemana(quinta); imprimeDiaSemana(sexta); imprimeDiaSemana(sabado); imprimeDiaSemana(domingo);
  • 5. private static void imprimeDiaSemana(int dia){ switch (dia) { case 1: System.out.println("Segunda-feira"); break; case 2: System.out.println("Terça-feira"); break; case 3: System.out.println("Quarta-feira"); break; case 4: System.out.println("Quinta-feira"); break; case 5: System.out.println("Sexta-feira"); break; case 6: System.out.println("Sábado"); break; case 7: System.out.println("Domingo"); break; } }
  • 7. public enum DiaSemana { SEGUNDA, TERCA, QUARTA, QUINTA, SEXTA, SABADO, DOMINGO; }
  • 8. DiaSemana segunda = DiaSemana.SEGUNDA; DiaSemana terca = DiaSemana.TERCA; DiaSemana quarta = DiaSemana.QUARTA; DiaSemana quinta = DiaSemana.QUINTA; DiaSemana sexta = DiaSemana.SEXTA; DiaSemana sabado = DiaSemana.SABADO; DiaSemana domingo = DiaSemana.DOMINGO; System.out.println("Usando enum"); imprimeDiaSemana(segunda); imprimeDiaSemana(terca); imprimeDiaSemana(quarta); imprimeDiaSemana(quinta); imprimeDiaSemana(sexta); imprimeDiaSemana(sabado); imprimeDiaSemana(domingo);
  • 9. private static void imprimeDiaSemana(DiaSemana dia){ switch (dia) { case SEGUNDA: System.out.println("Segunda-feira"); break; case TERCA: System.out.println("Terça-feira"); break; case QUARTA: System.out.println("Quarta-feira"); break; case QUINTA: System.out.println("Quinta-feira"); break; case SEXTA: System.out.println("Sexta-feira"); break; case SABADO: System.out.println("Sábado"); break; case DOMINGO: System.out.println("Domingo"); break; } }
  • 13. http://loiane.training Fórum para dúvidas + certificado do curso. Cadastro em: