r/learnjava • • Nov 21 '14

learning about methods, question

it's not covered in the text so i figured i'd ask. so basically methods = a way to make your text nice and clean and readable. so if u did something like checking if a number is like odd or even or something that involves if statements or else statements, you put it in a method then call on that so your "main method (am i using the correct terminology)" is readable and cool.

also, do all methods u make need to be after the main method? can it be before the main method like you have something called checkEvenOrOdd() before the main method, then in the main method u call on that. is that wrong ? thx bros

0 Upvotes

13 comments sorted by

View all comments

1

u/KillerAlt Nov 21 '14

I just wanted to add something to this conversation to hopefully clarify something for you. Methods are something a class does, like a door opening would be a method from a door class. A door in a game might also be able to break, that's another thing a door can do. I know you are at the very beginning stages so you don't know a whole lot about objects or classes yet, but this will be good for you to keep in mind later on down the road. Methods don't just make your code clean, they are a huge part of how your programs do everything they do.