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/seronis Nov 21 '14

Is this meant to be in /r/learnprogramming instead of /r/learnjava ?

Java doesnt require forward declarations in the sense that C and C++ do. All methods in a class can see each other regardless of their position within the class.

2

u/imgonnabethebest Nov 21 '14

idk bro java is my first language so i dont know if other languages have methods too or how that works

2

u/seronis Nov 21 '14

No problem. Just the question you asked isnt relevant to java but it is relevant to C and C++ so i wasnt sure if you were even talking about java.

2

u/s0lv3 Nov 24 '14

His question is definitely relevant to Java he just is not sure how to ask it.