I recently came across the following methods. I tried googling and did an example to see the difference by defining the methods as follows; both seems to be the same. But, i
Both code is same and compiler will convert it to same byte code if you decompile the code. However it is general practice (not rule of thumb) to begin code with access specifier rather than other keywords.
public abstract void methodName();
abstract public void methodName();
compiler converts both methods to below code
public abstract void methodName();
It's the same. Don't worry. Two similar declarations of abstract
method.
There is no difference as far as functionality is concerned but, regardless of whichever you choose, it's best to stay consistent.
That being said, I've almost never seen the abstract public
used before. So, from a coding standards point of view, public abstract
is probably going to be more easily recognized by more people.
public abstract void methodName();
abstract public void methodName();
These two methods are same similar example is
public static void main(String args[]);
static public void main(String args[]);
thus above two are same.It is just our wish how we want to write.
both are modifiers , you can use in any order