By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,798 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,798 IT Pros & Developers. It's quick & easy.

public static or static public

P: n/a
Hello,

I just came across some sample code where a variable has been defined as:
static public final int TABLE = 1, LIST = 2;

I was wondering if there is a difference to writing
public static final int TABLE = 1,...?

Cheers,
Petra
Jul 17 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Petra Neumann wrote:
Hello,

I just came across some sample code where a variable has been defined as:
static public final int TABLE = 1, LIST = 2;

I was wondering if there is a difference to writing
public static final int TABLE = 1,...?


These are equivalent. In general, the order of the modifiers in a
declaration is not significant.

Ray
Jul 17 '05 #2

P: n/a
66***@web.de (Petra Neumann) wrote:
I just came across some sample code where a variable has been defined as:
static public final int TABLE = 1, LIST = 2;

I was wondering if there is a difference to writing
public static final int TABLE = 1,...?


From section 8.3.1 of the Java 2 Language Specification:
"If two or more (distinct) field modifiers appear in a field
declaration, it is customary, though not required, that they
appear in the order consistent with that shown above in the
production for FieldModifier."
(http://java.sun.com/docs/books/jls/s...doc.html#78091)

That order is:
"public protected private static final transient volatile"
(ibid).

So they can appear in any order, but there is a *recommended*
ordering.

===

Now for my occasional reminder to everyone that comp.lang.java is not
an "official" newsgroup, and that you'll probably get a lot better
response using one of the worldwide Java newsgroups.

comp.lang.java was retired in 1996, replaced by a number of more
specific newsgroups. Most people don't see postings on comp.lang.java,
because only a few news servers still carry it. Google Groups carries
it for its historical value, and a few ISPs (mainly U.S.
cable-Internet providers) seem to carry it out of ignorance :-)

The current worldwide Java newsgroups are:

comp.lang.java.3d 3D Graphics API's for the Java language
comp.lang.java.advocacy Support for and criticism of the Java System
comp.lang.java.announce Announcements re the Java System (Moderated)
comp.lang.java.beans Java software components (JavaBeans)
comp.lang.java.corba Topics relating to Java and CORBA
comp.lang.java.databases Databases, java.sql, JDBC, ODBC
comp.lang.java.gui GUI toolkits and windowing: AWT, IFC etc
comp.lang.java.help Set-up problems, catch-all first aid
comp.lang.java.machine JVM, native methods, hardware
comp.lang.java.programmer Programming in the Java language
comp.lang.java.security Security issues raised by Java
comp.lang.java.softwaretools IDEs, browsers, compilers, other tools.
Jul 17 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.