help

Discussion in 'Java' started by Hatter, Dec 12, 2006.

  1. Hatter

    Hatter Guest

    default access in class,
    I declare a class like:
    class ClassA
    {
    int getValue()
    {
    return 0;
    }
    }

    then what is the type of method:getValue?
    public?protected?or private?

    I use ClassA.class.GetMethods() to get the method list of class ClassA,
    but getValue was not in the list.
    Can anyone tell me why??
    Hatter, Dec 12, 2006
    #1
    1. Advertising

  2. Hatter

    trippy Guest

    In article <>,
    Hatter took the hamburger meat, threw it on the grill, and I said "Oh
    Wow"...

    > default access in class,
    > I declare a class like:
    > class ClassA
    > {
    > int getValue()
    > {
    > return 0;
    > }
    > }
    >
    > then what is the type of method:getValue?


    int

    > public?protected?or private?


    I believe the modifier would be public.

    >
    > I use ClassA.class.GetMethods() to get the method list of class ClassA,
    > but getValue was not in the list.
    > Can anyone tell me why??
    >


    Try ClassA.getMethods()

    --
    trippy
    mhm31x9 Smeeter#29 WSD#30
    sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

    NP: "The American Way" -- Sacred Reich

    "Now, technology's getting better all the time and that's fine,
    but most of the time all you need is a stick of gum, a pocketknife,
    and a smile."

    -- Robert Redford "Spy Game"
    trippy, Dec 12, 2006
    #2
    1. Advertising

  3. trippy wrote:
    >> default access in class,
    >> I declare a class like:
    >> class ClassA
    >> {
    >> int getValue()
    >> {
    >> return 0;
    >> }
    >> }
    >>
    >> then what is the type of method:getValue?

    >
    > int
    >
    >> public?protected?or private?

    >
    > I believe the modifier would be public.


    It is not public but is accessible in the package in which it is declared.

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Dec 12, 2006
    #3
  4. Hatter

    trippy Guest

    In article <4Xqfh.164312$>, Knute Johnson took
    the hamburger meat, threw it on the grill, and I said "Oh Wow"...

    > trippy wrote:
    > >> default access in class,
    > >> I declare a class like:
    > >> class ClassA
    > >> {
    > >> int getValue()
    > >> {
    > >> return 0;
    > >> }
    > >> }
    > >>
    > >> then what is the type of method:getValue?

    > >
    > > int
    > >
    > >> public?protected?or private?

    > >
    > > I believe the modifier would be public.

    >
    > It is not public but is accessible in the package in which it is declared.
    >


    Right.

    http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#
    104285

    Thanks.

    --
    trippy
    mhm31x9 Smeeter#29 WSD#30
    sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

    NP: "The American Way" -- Sacred Reich

    "Now, technology's getting better all the time and that's fine,
    but most of the time all you need is a stick of gum, a pocketknife,
    and a smile."

    -- Robert Redford "Spy Game"
    trippy, Dec 12, 2006
    #4
  5. Hatter

    Hatter Guest

    I got it, thanks.

    On Dec 12, 1:50 pm, trippy <> wrote:
    > In article <4Xqfh.164312$>, Knute Johnson took
    > the hamburger meat, threw it on the grill, and I said "Oh Wow"...
    >
    >
    >
    > > trippy wrote:
    > > >> default access in class,
    > > >> I declare a class like:
    > > >> class ClassA
    > > >> {
    > > >> int getValue()
    > > >> {
    > > >> return 0;
    > > >> }
    > > >> }

    >
    > > >> then what is the type of method:getValue?

    >
    > > > int

    >
    > > >> public?protected?or private?

    >
    > > > I believe the modifier would be public.

    >
    > > It is not public but is accessible in the package in which it is declared.Right.

    >
    > http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#
    > 104285
    >
    > Thanks.
    >
    > --
    > trippy
    > mhm31x9 Smeeter#29 WSD#30
    > sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM
    >
    > NP: "The American Way" -- Sacred Reich
    >
    > "Now, technology's getting better all the time and that's fine,
    > but most of the time all you need is a stick of gum, a pocketknife,
    > and a smile."
    >
    > -- Robert Redford "Spy Game"
    Hatter, Dec 12, 2006
    #5
  6. Andrew Thompson, Dec 12, 2006
    #6
  7. Hatter

    Chris Uppal Guest

    Knute Johnson wrote:

    > It is not public but is accessible in the package in which it is declared.


    Just to add: The default visibility level is often called either "default
    access" or "package private".

    -- chris
    Chris Uppal, Dec 12, 2006
    #7
  8. Andrew Thompson wrote:
    > trippy wrote:
    > ...
    >> http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#
    >> 104285

    >
    > To protect long URL's from line-wrap,
    > enclose them in '<', '>'. E.G.
    > <http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#104285>
    >
    > Andrew T.
    >


    That's a neat trick that I didn't know!

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Dec 12, 2006
    #8
  9. Knute Johnson wrote:
    > Andrew Thompson wrote:
    > > trippy wrote:
    > > ...
    > >> http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#
    > >> 104285

    > >
    > > To protect long URL's from line-wrap,
    > > enclose them in '<', '>'. E.G.
    > > <http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#104285>

    ....
    > That's a neat trick that I didn't know!


    Yeah, that one is handy to know.

    Unfortunately not even *that* will fix the BA URL
    anchors that are used in the JavaDocs.

    E.G.
    <http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JLabel.html#JLabel(java.lang.String,
    int)>
    ...or..
    <http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JLabel.html#JLabel(java.lang.String,%20int)>

    I tried to put a bug report/RFE in with Sun to have
    the standard doclet changed, but never heard anything
    after the original auto-generated email.. :-(

    Andrew T.
    Andrew Thompson, Dec 12, 2006
    #9
  10. Chris Uppal wrote:
    > Knute Johnson wrote:
    >
    >> It is not public but is accessible in the package in which it is declared.

    >
    > Just to add: The default visibility level is often called either "default
    > access" or "package private".
    >
    > -- chris
    >
    >


    I tried to be careful not to use words that were not in the JLS and
    probably should have just quoted it.

    From the JLS, third edition:

    "If a top level class or interface type is not declared public, then it
    may be accessed only from within the package in which it is declared."

    --

    Knute Johnson
    email s/nospam/knute/
    Knute Johnson, Dec 12, 2006
    #10
  11. Hatter

    Daniel Pitts Guest

    Hatter wrote:
    > default access in class,
    > I declare a class like:
    > class ClassA
    > {
    > int getValue()
    > {
    > return 0;
    > }
    > }
    >
    > then what is the type of method:getValue?
    > public?protected?or private?
    >
    > I use ClassA.class.GetMethods() to get the method list of class ClassA,
    > but getValue was not in the list.
    > Can anyone tell me why??


    Specifically, ClassA.class.getDeclaredMethods() should return the
    method, because it returns all methods declared by that class, public
    or otherwise,
    Daniel Pitts, Dec 13, 2006
    #11
  12. Hatter

    trippy Guest

    In article <19Bfh.57654$>, Knute Johnson took the
    hamburger meat, threw it on the grill, and I said "Oh Wow"...

    > Andrew Thompson wrote:
    > > trippy wrote:
    > > ...
    > >> http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#
    > >> 104285

    > >
    > > To protect long URL's from line-wrap,
    > > enclose them in '<', '>'. E.G.
    > > <http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#104285>
    > >
    > > Andrew T.
    > >

    >
    > That's a neat trick that I didn't know!
    >


    Me either. Thanks Andrew.

    --
    trippy
    mhm31x9 Smeeter#29 WSD#30
    sTaRShInE_mOOnBeAm aT HoTmAil dOt CoM

    NP: "The American Way" -- Sacred Reich

    "Now, technology's getting better all the time and that's fine,
    but most of the time all you need is a stick of gum, a pocketknife,
    and a smile."

    -- Robert Redford "Spy Game"
    trippy, Dec 13, 2006
    #12
  13. trippy wrote:
    > In article <19Bfh.57654$>, Knute Johnson took the
    > hamburger meat, threw it on the grill, and I said "Oh Wow"...
    >
    >> Andrew Thompson wrote:
    >>> trippy wrote:
    >>> ...
    >>>> http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#
    >>>> 104285
    >>> To protect long URL's from line-wrap,
    >>> enclose them in '<', '>'. E.G.
    >>> <http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#104285>
    >>>
    >>> Andrew T.
    >>>

    >> That's a neat trick that I didn't know!
    >>

    >
    > Me either. Thanks Andrew.


    It is can be better to use
    <URL:http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#104285>,
    which was once part of the official URL standard. It was deleted from
    the standard for lack of use, but is still supported in some software.

    --
    John W. Kennedy
    "The blind rulers of Logres
    Nourished the land on a fallacy of rational virtue."
    -- Charles Williams. "Taliessin through Logres: Prelude"
    John W. Kennedy, Dec 13, 2006
    #13
  14. John W. Kennedy wrote:
    ....
    > It is can be better to use
    > <URL:http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#104285>,
    > which was once part of the official URL standard. ..


    Aaah yes, I knew there was a still better form of
    URL representation, but had forgotten what it was,
    so decided it better not to comment.

    > ...It was deleted from
    > the standard for lack of use, but is still supported in some software.


    I am not sure if this has been asked/answered before,
    but do you know of any software that would recognise
    the full form, but *not* the more abbreviated form I first
    listed?
    (The short form is an entire 4 *chars.* shorter, after all!)

    Oh, and as a side comment. If *you* have control over the URL,
    a 'short, stable URL' lacking in characters such as '-', '_', '.', ' ',
    'CAPITALS' or other extraneous/confusing characters, is way
    better than any scheme to try and protect them from wrap,
    after the effect..

    A 'good' URL - beats any/all efforts to fix a 'bad' one.

    Andrew T.
    Andrew Thompson, Dec 13, 2006
    #14
  15. Hatter

    Daniel Pitts Guest

    Andrew Thompson wrote:
    > John W. Kennedy wrote:
    > ...
    > > It is can be better to use
    > > <URL:http://java.sun.com/docs/books/jls/second_edition/html/names.doc.html#104285>,
    > > which was once part of the official URL standard. ..

    >
    > Aaah yes, I knew there was a still better form of
    > URL representation, but had forgotten what it was,
    > so decided it better not to comment.
    >
    > > ...It was deleted from
    > > the standard for lack of use, but is still supported in some software.

    >
    > I am not sure if this has been asked/answered before,
    > but do you know of any software that would recognise
    > the full form, but *not* the more abbreviated form I first
    > listed?
    > (The short form is an entire 4 *chars.* shorter, after all!)
    >
    > Oh, and as a side comment. If *you* have control over the URL,
    > a 'short, stable URL' lacking in characters such as '-', '_', '.', ' ',
    > 'CAPITALS' or other extraneous/confusing characters, is way
    > better than any scheme to try and protect them from wrap,
    > after the effect..
    >
    > A 'good' URL - beats any/all efforts to fix a 'bad' one.
    >
    > Andrew T.


    URLs that bother me:
    If it ends with an extension that specifies the generating technology,
    not the response type:
    * http://someplace.com/showForm.jsp -- should probably be
    showForm.html
    * http://someplace.com/index.php -- injection attack anyone?
    * whatever.asp, whatever.cgi, etc... -- you get the point

    If it can become invalid for stupid reasons.
    * http://www.mycompany.com/hr/John_Smith/benefits.html -- Well, John
    Smith just quit, everyone has to update their bookmarks.

    If it doesn't describe the resource.
    * http://tinyurl.com/garbage -- don't get me started on tinyurl

    If it contains the words geocities, myspace, anglefire, etc...
    * Do you REALLY need an example :)
    Daniel Pitts, Dec 13, 2006
    #15
  16. Andrew Thompson wrote:
    > I am not sure if this has been asked/answered before,
    > but do you know of any software that would recognise
    > the full form, but *not* the more abbreviated form I first
    > listed?
    > (The short form is an entire 4 *chars.* shorter, after all!)


    I've been using <URL:.> for too long to remember, now, but at one point
    I know I needed it. I've been using Netscape/Mozilla/Firefox for a very
    long time, so it would be somewhere in that chain. But I don't know the
    current state of affairs.

    --
    John W. Kennedy
    "The blind rulers of Logres
    Nourished the land on a fallacy of rational virtue."
    -- Charles Williams. "Taliessin through Logres: Prelude"
    John W. Kennedy, Dec 14, 2006
    #16
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?dHJlbGxvdzQyMg==?=

    HELP! HELP! HELP! Opening Web Application Project Error

    =?Utf-8?B?dHJlbGxvdzQyMg==?=, Feb 20, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    741
    =?Utf-8?B?dHJlbGxvdzQyMg==?=
    Feb 20, 2004
  2. Harvey
    Replies:
    0
    Views:
    665
    Harvey
    Jul 16, 2004
  3. Harvey
    Replies:
    1
    Views:
    817
    Daniel
    Jul 16, 2004
  4. =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?=

    HELP - HELP - HELP

    =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?=, Mar 9, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    660
    Eliyahu Goldin
    Mar 9, 2006
  5. Buster

    Help, Help, Help

    Buster, Oct 4, 2003, in forum: Java
    Replies:
    3
    Views:
    460
    Saager
    Oct 30, 2003
Loading...

Share This Page