Possible to have a function thats not a method in java? -


in java program i'm writing i’m finding i’m clogging main() method lot of code make hard understand/read. due lot of error checking i’m doing. result want write quick function going used 1 method improve readability.

is writing method within class option or there other alternatives?

is writing method within class option or there other alternatives?

it depends:

  • if methods should belong class, should declared private or protected methods in class, depending if class can inherited or not.

  • if methods should reused in other classes, better move utility classes public. example, check if string empty , validating if not null. note example there methods covering these validations in utility classes apache common langs, explicitely stringutils#isempty(string).

by way, java has methods, no functions.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -