50 - Orientação Objetos - Métodos pt 07 - Parâmetros tipo referência pt 02

50 - Orientação Objetos - Métodos pt 07 - Parâmetros tipo referência pt 02

Understanding Parameter Passing by Reference

Introduction to Parameter Passing

  • The discussion begins with an introduction to the topic of parameter passing in programming, specifically focusing on passing parameters by reference.
  • The speaker references a previous lesson where they discussed how objects are passed in programming, emphasizing that when passing by reference, the actual reference to the object is sent rather than a copy.

Implications of Passing by Reference

  • It is highlighted that changes made to an object through one reference will affect all references pointing to that object, which can lead to unintended consequences if not managed carefully.
  • An example is provided where two student objects (student 01 and student 02) are manipulated within a method, demonstrating how altering one affects the other due to shared references.

Demonstrating Object Modification

  • The speaker modifies properties of student objects within a print method, showing how these changes reflect across different instances when printed.
  • A specific change is made to the name property of student 01, illustrating that modifications persist beyond the scope of the method call.

Complications Arising from Shared References

  • The order of operations in code execution is altered, leading to further exploration of how shared references impact output during multiple calls.
  • When printing both students after modifications, it becomes evident that changes made earlier affect subsequent outputs due to retained references.

Best Practices for Managing Object States

  • The speaker emphasizes best practices in programming: avoid altering data directly on passed objects. Instead, create new instances or return modified copies.
Video description

Melhor, maior, e mais completo curso de Java em português grátis de toda Internet está de volta. Maratona Java Virado No Jiraya. Regravado desde a aula 0, com extrema qualidade, utilizando a última versão do Java, com fonte 22 e fundo branco celestial. O Maratona Java Virado no Jiraya é o único curso que você vai precisar para aprender Java. São mais de 250 aulas onde nós cobrimos praticamente o núcleo inteiro da linguagem. Desde o primeiro Olá mundo, até Orientação a Objetos, Coleções, Conexão com banco de dados, Tratamento de exeções, Threads, Programação funcional e muito mais. Meu amigo... é aula para CARAMBA. Só não aprende Java quem não quer. Centenas de pessoas fizeram o curso anterior e conseguiram entrar no mercado de trabalho, imagina esse que é melhor, mais completo e atualizado. E se você ainda não estiver satisfeito com essa belezura e quiser alavancar na carreira ainda mais rápido com as pessoas mais inteligentes, esforçadas, e gente boa do Brasil, além de ainda ter nosso suporte durante o curso, faça parte do nosso clube de membros https://www.youtube.com/channel/UCjF0OccBT05WxsJb2zNkL4g/join Mais informações e contato: http://devdojo.academy Design de tudo que é bonitinho no DevDojo: https://www.magiesocial.com Facebook: https://www.facebook.com/devdojobr Voz do Cid Moreira nos vídeos: https://www.linkedin.com/in/williamsuane/ Editor de vídeo: https://www.linkedin.com/in/wildneisuane/ (sem esse cara não existiria DevDojo, o mínimo que você pode fazer por um curso desses é ir no LinkedIn e agradecer pelo trabalho dele) Código Fonte: https://github.com/devdojobr/maratona-java-virado-no-jiraya