Advantages of using private static methods in a class
- From: "HalcyonWild" <Halcyon.Wild@xxxxxxxxx>
- Date: 31 Dec 2005 04:49:48 -0800
Hello all,
I generally make small helper methods, private and static, inside my
java class as , for example, below.
//can use substring too, but this for example
private static String getFirstCharacter(String str)
{
char [] c = str.toCharArray[];
return ""+c[0];
}
I am having doubts if static methods is a good thing to do. Is it any
better or worse, if I make the method non-static. Is this a good
practice.
I searched previous group posts on Google to find if this has been
discussed before, but could not find it. (It returns almost all posts
with private and static in them).
What I understand is that the call is bound at compile time, if the
method is marked as static, and therefore you can consider it as good
as inline code. But I think I might be forgetting something, I am not
sure. (I moved to Java programming about a year ago).
I am going to read up more on that today, I thought I could have your
opinions too.
BTW, A very Happy New Year in advance. :)
Thanks.
.
- Follow-Ups:
- Re: Advantages of using private static methods in a class
- From: andreas kinell
- Re: Advantages of using private static methods in a class
- Prev by Date: Re: Callbacks, and using interfaces as arguments
- Next by Date: Re: Callbacks, and using interfaces as arguments
- Previous by thread: Callbacks, and using interfaces as arguments
- Next by thread: Re: Advantages of using private static methods in a class
- Index(es):