help

H

Hatter

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??
 
T

trippy

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"
 
T

trippy

Knute Johnson took said:
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"
 
C

Chris Uppal

Knute said:
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
 
A

Andrew Thompson

Knute said:
....
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, int)>

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.
 
K

Knute Johnson

Chris said:
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."
 
D

Daniel Pitts

Hatter said:
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,
 
T

trippy

Knute Johnson took the said:
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"
 
A

Andrew Thompson

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.
 
D

Daniel Pitts

Andrew said:
John W. Kennedy wrote:
...

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.


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 :)
 
J

John W. Kennedy

Andrew said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top