#Probably an easily answered noob question about Java structure

16 messages · Page 1 of 1 (latest)

stark pilot
#

So a while ago I wrote a program on paper and now I want to implement it. I have many methods each defined on their own page. What I am trying to figure out is, do I just define these methods one after another in a single document? Or should each one be in a self-contained file?

runic compassBOT
#

This post has been reserved for your question.

Hey @stark pilot! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

waxen pagoda
#

You can define methods one after the other outside of your main method and call them from main, but they will be static methods.
If you create another class, you must create an object to invoke each method, generally.

#

methods are defined up top above the main method and called within the main method on bottom.

#

hope this helps

narrow wyvern
#

you can define methods anywhere tho

#

but it's recommended to put them above main for some reason

#

like what we had in c/cpp

stray sundial
narrow wyvern
#

well, anywhere withtin the class body and outside of other method bodies

stray sundial
narrow wyvern
#

and other shit

old inlet
#

anywhere directly in a type body

old inlet
# stark pilot So a while ago I wrote a program on paper and now I want to implement it. I have...

if you want to implement something in java, a spec of functions is generally not enough, since java is so heavily and fundamentally OOP. you could make all your method static in the main method to kinda disregard OOP, but then you may as well not use java.

i think you should go back to your design and add OOP, then you can implement that more directly into java.

https://dev.java/learn/oop