≡ Menu

Podcast Episode 7 – Methods

  • Methods are the key to making programs flexible, useful and easy to code
  • Methods allow us to re-run specific pieces of code at any given moment
    • ex. user clicks “login”, so now we need to validate their credentials
  • Methods are a way to gather or “clump together”, code into logical groupings.
    • Group code together by tasks: validate user, create new user, change user’s password
  • Methods can allow you to extract a piece of information once they’ve completed their execution
    • this is called a “return value”
    • ex. isUserValid? Yes or No? The answer to the question isUserValid is the return value, which is a boolean
  • Methods don’t HAVE to return anything though, like if you just want to create a new user. You call the “createNewUser” method, and the user can get inserted into a database. We don’t need to know anything else about the operation.

Homework

Read the following post about methods: https://howtoprogramwithjava.com/what-is-a-method-in-java/

Dude... Seriously... Take our FREE Java Video Tutorials Course...
You'll receive a new Java Video Tutorial lecture straight to your inbox, twice a week.  How cool is that?

{ 2 comments… add one }

  • Cassandra S. January 27, 2015, 10:44 pm

    Thank you Trevor. Learning Java in college has been entirely independent, with a web based book that is filled with jargon which isn’t friendly to those new at code. I would read instructions on methods and classes for hours and still find myself clueless as to what a method even was. This is a perfect tool for beginners and I intend to be a regular on your website now for sometime.

    Cheers

Leave a Comment