SlideShare uma empresa Scribd logo
LINGUAGENS DE PROGRAMAÇÃO E
COMPILADORES– AULA 2
Métodos em java
4º ANO DE ENGENHARIA INFORMÁTICA
MÉTODOS
9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
MÉTODOS
Quando alguém pedir para sacar (levantar dinheiro), ele também vai
dizer quanto quer sacar. Por isso precisamos declarar o método com
algo dentro dos parênteses - o que vai aí dentro é chamado de
argumento do método (ou parâmetro). Essa variável é uma variável
comum, chamada também de temporária ou local, pois, ao final da
execução desse método, ela deixa de existir.
Repare que, nesse caso, a conta pode estourar o limite fixado pelo
banco. Mais para frente, evitaremos essa situação, e de uma
maneira muito elegante.
Da mesma forma, temos o método para depositar alguma quantia:
9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
MÉTODOS
9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
MÉTODOS
Observe que não usamos uma variável auxiliar e, além disso, usamos
a abreviação += para deixar o método bem simples. O += soma
quantidade ao valor antigo do saldo e guarda no próprio saldo, o
valor resultante.
Para mandar uma mensagem ao objecto e pedir que ele execute um
método, também usamos o ponto. O termo usado para isso é
invocação de método.
9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
MÉTODOS
O código a seguir saca dinheiro e depois deposita outra quantia na
nossa conta:
9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
MÉTODOS
Criação do formulário de Registo de Contas GUI
9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila

Mais conteúdo relacionado

Último

cronograma-enem-2024-planejativo-estudos.pdf
cronograma-enem-2024-planejativo-estudos.pdfcronograma-enem-2024-planejativo-estudos.pdf
cronograma-enem-2024-planejativo-estudos.pdf
todorokillmepls
 
- TEMPLATE DA PRATICA - Psicomotricidade.pptx
- TEMPLATE DA PRATICA - Psicomotricidade.pptx- TEMPLATE DA PRATICA - Psicomotricidade.pptx
- TEMPLATE DA PRATICA - Psicomotricidade.pptx
LucianaCristina58
 
Estrutura Pedagógica - Laboratório de Educação a Distância.ppt
Estrutura Pedagógica - Laboratório de Educação a Distância.pptEstrutura Pedagógica - Laboratório de Educação a Distância.ppt
Estrutura Pedagógica - Laboratório de Educação a Distância.ppt
livrosjovert
 
Slides Lição 11, Central Gospel, Os Mortos Em CRISTO, 2Tr24.pptx
Slides Lição 11, Central Gospel, Os Mortos Em CRISTO, 2Tr24.pptxSlides Lição 11, Central Gospel, Os Mortos Em CRISTO, 2Tr24.pptx
Slides Lição 11, Central Gospel, Os Mortos Em CRISTO, 2Tr24.pptx
LuizHenriquedeAlmeid6
 
Rimas, Luís Vaz de Camões. pptx
Rimas, Luís Vaz de Camões.          pptxRimas, Luís Vaz de Camões.          pptx
Rimas, Luís Vaz de Camões. pptx
TomasSousa7
 
1ª LEI DE OHN, CARACTERISTICAS IMPORTANTES.
1ª LEI DE OHN, CARACTERISTICAS IMPORTANTES.1ª LEI DE OHN, CARACTERISTICAS IMPORTANTES.
1ª LEI DE OHN, CARACTERISTICAS IMPORTANTES.
LeticiaRochaCupaiol
 
05-os-pre-socraticos sociologia-28-slides.pptx
05-os-pre-socraticos sociologia-28-slides.pptx05-os-pre-socraticos sociologia-28-slides.pptx
05-os-pre-socraticos sociologia-28-slides.pptx
ValdineyRodriguesBez1
 
Sistema de Bibliotecas UCS - Chronica do emperador Clarimundo, donde os reis ...
Sistema de Bibliotecas UCS - Chronica do emperador Clarimundo, donde os reis ...Sistema de Bibliotecas UCS - Chronica do emperador Clarimundo, donde os reis ...
Sistema de Bibliotecas UCS - Chronica do emperador Clarimundo, donde os reis ...
Biblioteca UCS
 
Potenciação e Radiciação de Números Racionais
Potenciação e Radiciação de Números RacionaisPotenciação e Radiciação de Números Racionais
Potenciação e Radiciação de Números Racionais
wagnermorais28
 
Atividade de reforço de matemática 2º ano
Atividade de reforço de matemática 2º anoAtividade de reforço de matemática 2º ano
Atividade de reforço de matemática 2º ano
fernandacosta37763
 
Introdução à Sociologia: caça-palavras na escola
Introdução à Sociologia: caça-palavras na escolaIntrodução à Sociologia: caça-palavras na escola
Introdução à Sociologia: caça-palavras na escola
Professor Belinaso
 
AVALIAÇÃO DIAGNÓSTICA - 8º ANO 2024.pptx
AVALIAÇÃO DIAGNÓSTICA - 8º ANO 2024.pptxAVALIAÇÃO DIAGNÓSTICA - 8º ANO 2024.pptx
AVALIAÇÃO DIAGNÓSTICA - 8º ANO 2024.pptx
AntonioVieira539017
 
UFCD_10145_Enquadramento do setor farmacêutico_indice.pdf
UFCD_10145_Enquadramento do setor farmacêutico_indice.pdfUFCD_10145_Enquadramento do setor farmacêutico_indice.pdf
UFCD_10145_Enquadramento do setor farmacêutico_indice.pdf
Manuais Formação
 
Leis de Mendel - as ervilhas e a maneira simples de entender.ppt
Leis de Mendel - as ervilhas e a maneira simples de entender.pptLeis de Mendel - as ervilhas e a maneira simples de entender.ppt
Leis de Mendel - as ervilhas e a maneira simples de entender.ppt
PatriciaZanoli
 
Aula 2 - Revisando o significado de fração - Parte 2.pptx
Aula 2 - Revisando o significado de fração - Parte 2.pptxAula 2 - Revisando o significado de fração - Parte 2.pptx
Aula 2 - Revisando o significado de fração - Parte 2.pptx
LILIANPRESTESSCUDELE
 
000. Para rezar o terço - Junho - mês do Sagrado Coração de Jesús.pdf
000. Para rezar o terço - Junho - mês do Sagrado Coração de Jesús.pdf000. Para rezar o terço - Junho - mês do Sagrado Coração de Jesús.pdf
000. Para rezar o terço - Junho - mês do Sagrado Coração de Jesús.pdf
YeniferGarcia36
 
A SOCIOLOGIA E O TRABALHO: ANÁLISES E VIVÊNCIAS
A SOCIOLOGIA E O TRABALHO: ANÁLISES E VIVÊNCIASA SOCIOLOGIA E O TRABALHO: ANÁLISES E VIVÊNCIAS
A SOCIOLOGIA E O TRABALHO: ANÁLISES E VIVÊNCIAS
HisrelBlog
 
347018542-PAULINA-CHIZIANE-Balada-de-Amor-ao-Vento-pdf.pdf
347018542-PAULINA-CHIZIANE-Balada-de-Amor-ao-Vento-pdf.pdf347018542-PAULINA-CHIZIANE-Balada-de-Amor-ao-Vento-pdf.pdf
347018542-PAULINA-CHIZIANE-Balada-de-Amor-ao-Vento-pdf.pdf
AntnioManuelAgdoma
 
Vogais Ilustrados para alfabetização infantil
Vogais Ilustrados para alfabetização infantilVogais Ilustrados para alfabetização infantil
Vogais Ilustrados para alfabetização infantil
mamaeieby
 
D20 - Descritores SAEB de Língua Portuguesa
D20 - Descritores SAEB de Língua PortuguesaD20 - Descritores SAEB de Língua Portuguesa
D20 - Descritores SAEB de Língua Portuguesa
eaiprofpolly
 

Último (20)

cronograma-enem-2024-planejativo-estudos.pdf
cronograma-enem-2024-planejativo-estudos.pdfcronograma-enem-2024-planejativo-estudos.pdf
cronograma-enem-2024-planejativo-estudos.pdf
 
- TEMPLATE DA PRATICA - Psicomotricidade.pptx
- TEMPLATE DA PRATICA - Psicomotricidade.pptx- TEMPLATE DA PRATICA - Psicomotricidade.pptx
- TEMPLATE DA PRATICA - Psicomotricidade.pptx
 
Estrutura Pedagógica - Laboratório de Educação a Distância.ppt
Estrutura Pedagógica - Laboratório de Educação a Distância.pptEstrutura Pedagógica - Laboratório de Educação a Distância.ppt
Estrutura Pedagógica - Laboratório de Educação a Distância.ppt
 
Slides Lição 11, Central Gospel, Os Mortos Em CRISTO, 2Tr24.pptx
Slides Lição 11, Central Gospel, Os Mortos Em CRISTO, 2Tr24.pptxSlides Lição 11, Central Gospel, Os Mortos Em CRISTO, 2Tr24.pptx
Slides Lição 11, Central Gospel, Os Mortos Em CRISTO, 2Tr24.pptx
 
Rimas, Luís Vaz de Camões. pptx
Rimas, Luís Vaz de Camões.          pptxRimas, Luís Vaz de Camões.          pptx
Rimas, Luís Vaz de Camões. pptx
 
1ª LEI DE OHN, CARACTERISTICAS IMPORTANTES.
1ª LEI DE OHN, CARACTERISTICAS IMPORTANTES.1ª LEI DE OHN, CARACTERISTICAS IMPORTANTES.
1ª LEI DE OHN, CARACTERISTICAS IMPORTANTES.
 
05-os-pre-socraticos sociologia-28-slides.pptx
05-os-pre-socraticos sociologia-28-slides.pptx05-os-pre-socraticos sociologia-28-slides.pptx
05-os-pre-socraticos sociologia-28-slides.pptx
 
Sistema de Bibliotecas UCS - Chronica do emperador Clarimundo, donde os reis ...
Sistema de Bibliotecas UCS - Chronica do emperador Clarimundo, donde os reis ...Sistema de Bibliotecas UCS - Chronica do emperador Clarimundo, donde os reis ...
Sistema de Bibliotecas UCS - Chronica do emperador Clarimundo, donde os reis ...
 
Potenciação e Radiciação de Números Racionais
Potenciação e Radiciação de Números RacionaisPotenciação e Radiciação de Números Racionais
Potenciação e Radiciação de Números Racionais
 
Atividade de reforço de matemática 2º ano
Atividade de reforço de matemática 2º anoAtividade de reforço de matemática 2º ano
Atividade de reforço de matemática 2º ano
 
Introdução à Sociologia: caça-palavras na escola
Introdução à Sociologia: caça-palavras na escolaIntrodução à Sociologia: caça-palavras na escola
Introdução à Sociologia: caça-palavras na escola
 
AVALIAÇÃO DIAGNÓSTICA - 8º ANO 2024.pptx
AVALIAÇÃO DIAGNÓSTICA - 8º ANO 2024.pptxAVALIAÇÃO DIAGNÓSTICA - 8º ANO 2024.pptx
AVALIAÇÃO DIAGNÓSTICA - 8º ANO 2024.pptx
 
UFCD_10145_Enquadramento do setor farmacêutico_indice.pdf
UFCD_10145_Enquadramento do setor farmacêutico_indice.pdfUFCD_10145_Enquadramento do setor farmacêutico_indice.pdf
UFCD_10145_Enquadramento do setor farmacêutico_indice.pdf
 
Leis de Mendel - as ervilhas e a maneira simples de entender.ppt
Leis de Mendel - as ervilhas e a maneira simples de entender.pptLeis de Mendel - as ervilhas e a maneira simples de entender.ppt
Leis de Mendel - as ervilhas e a maneira simples de entender.ppt
 
Aula 2 - Revisando o significado de fração - Parte 2.pptx
Aula 2 - Revisando o significado de fração - Parte 2.pptxAula 2 - Revisando o significado de fração - Parte 2.pptx
Aula 2 - Revisando o significado de fração - Parte 2.pptx
 
000. Para rezar o terço - Junho - mês do Sagrado Coração de Jesús.pdf
000. Para rezar o terço - Junho - mês do Sagrado Coração de Jesús.pdf000. Para rezar o terço - Junho - mês do Sagrado Coração de Jesús.pdf
000. Para rezar o terço - Junho - mês do Sagrado Coração de Jesús.pdf
 
A SOCIOLOGIA E O TRABALHO: ANÁLISES E VIVÊNCIAS
A SOCIOLOGIA E O TRABALHO: ANÁLISES E VIVÊNCIASA SOCIOLOGIA E O TRABALHO: ANÁLISES E VIVÊNCIAS
A SOCIOLOGIA E O TRABALHO: ANÁLISES E VIVÊNCIAS
 
347018542-PAULINA-CHIZIANE-Balada-de-Amor-ao-Vento-pdf.pdf
347018542-PAULINA-CHIZIANE-Balada-de-Amor-ao-Vento-pdf.pdf347018542-PAULINA-CHIZIANE-Balada-de-Amor-ao-Vento-pdf.pdf
347018542-PAULINA-CHIZIANE-Balada-de-Amor-ao-Vento-pdf.pdf
 
Vogais Ilustrados para alfabetização infantil
Vogais Ilustrados para alfabetização infantilVogais Ilustrados para alfabetização infantil
Vogais Ilustrados para alfabetização infantil
 
D20 - Descritores SAEB de Língua Portuguesa
D20 - Descritores SAEB de Língua PortuguesaD20 - Descritores SAEB de Língua Portuguesa
D20 - Descritores SAEB de Língua Portuguesa
 

Destaque

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
Marius Sescu
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
Expeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
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
Neil 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 2024
Albert 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 Insights
Kurio // 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 2024
Search 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 summary
SpeakerHub
 
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 Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit 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 management
MindGenius
 
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
 

Destaque (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
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...
 

Aula 2 de Linguagens de Programação ISPGS

  • 1. LINGUAGENS DE PROGRAMAÇÃO E COMPILADORES– AULA 2 Métodos em java 4º ANO DE ENGENHARIA INFORMÁTICA
  • 2. MÉTODOS 9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
  • 3. MÉTODOS Quando alguém pedir para sacar (levantar dinheiro), ele também vai dizer quanto quer sacar. Por isso precisamos declarar o método com algo dentro dos parênteses - o que vai aí dentro é chamado de argumento do método (ou parâmetro). Essa variável é uma variável comum, chamada também de temporária ou local, pois, ao final da execução desse método, ela deixa de existir. Repare que, nesse caso, a conta pode estourar o limite fixado pelo banco. Mais para frente, evitaremos essa situação, e de uma maneira muito elegante. Da mesma forma, temos o método para depositar alguma quantia: 9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
  • 4. MÉTODOS 9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
  • 5. MÉTODOS Observe que não usamos uma variável auxiliar e, além disso, usamos a abreviação += para deixar o método bem simples. O += soma quantidade ao valor antigo do saldo e guarda no próprio saldo, o valor resultante. Para mandar uma mensagem ao objecto e pedir que ele execute um método, também usamos o ponto. O termo usado para isso é invocação de método. 9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
  • 6. MÉTODOS O código a seguir saca dinheiro e depois deposita outra quantia na nossa conta: 9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
  • 7. 9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila
  • 8. MÉTODOS Criação do formulário de Registo de Contas GUI 9/2/2015 Prof. Lic. Eugénio Nelson C. Camilo Dianguila