Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > help

Reply
 
 
Hatter
Guest
Posts: n/a
 
      12-12-2006
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??

 
Reply With Quote
 
 
 
 
trippy
Guest
Posts: n/a
 
      12-12-2006
In article <(E-Mail Removed) .com>,
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"



 
Reply With Quote
 
 
 
 
Knute Johnson
Guest
Posts: n/a
 
      12-12-2006
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/
 
Reply With Quote
 
trippy
Guest
Posts: n/a
 
      12-12-2006
In article <4Xqfh.164312$(E-Mail Removed)>, 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/s...ames.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"



 
Reply With Quote
 
Hatter
Guest
Posts: n/a
 
      12-12-2006
I got it, thanks.

On Dec 12, 1:50 pm, trippy <(E-Mail Removed)> wrote:
> In article <4Xqfh.164312$(E-Mail Removed)>, 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/s...ames.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"


 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      12-12-2006
trippy wrote:
....
> http://java.sun.com/docs/books/jls/s...ames.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.

 
Reply With Quote
 
Chris Uppal
Guest
Posts: n/a
 
      12-12-2006
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


 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      12-12-2006
Andrew Thompson wrote:
> trippy wrote:
> ...
>> http://java.sun.com/docs/books/jls/s...ames.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/
 
Reply With Quote
 
Andrew Thompson
Guest
Posts: n/a
 
      12-12-2006
Knute Johnson wrote:
> Andrew Thompson wrote:
> > trippy wrote:
> > ...
> >> http://java.sun.com/docs/books/jls/s...ames.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/...va.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.

 
Reply With Quote
 
Knute Johnson
Guest
Posts: n/a
 
      12-12-2006
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/
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Help Help Help Pentax S5i Help needed (Please) The Martian Digital Photography 14 06-20-2008 07:56 AM
HELP - HELP - HELP =?Utf-8?B?S2ltb24gSWZhbnRpZGlz?= ASP .Net 4 03-09-2006 12:46 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 1 07-16-2004 01:12 PM
HELP WANTED HELP WANTED HELP WANTED Harvey ASP .Net 0 07-16-2004 10:00 AM
HELP! HELP! HELP! Opening Web Application Project Error =?Utf-8?B?dHJlbGxvdzQyMg==?= ASP .Net 0 02-20-2004 05:16 PM



Advertisments