simply java questions - cd ...

T

Thomas

Sorry I incorrectly presented the problem in my previous post : The
structure of the files is [an ought to be ] like that :
-Function.java
-RPN.java
-operand.java
-Symbol.java
--my_package:
-Stack.java
.................
========================================================

The Stack use the Sybmol class. I got unrecognized symbol Symbol in Stack.
What should i do ?
 
R

Roedy Green

Sorry I incorrectly presented the problem in my previous post : The
structure of the files is [an ought to be ] like that :
-Function.java
-RPN.java
-operand.java
-Symbol.java
--my_package:
-Stack.java

When you have more than one class, you put classes in a package, and
put the *.java files in the structure to reflect packages.
see http://mindprod.com/jgloss/package.html


Further all class names and hence *.java file names must begin with a
capital letter.

See http://mindprod.com/jgloss/naming.html
 
L

Lew

Thomas said:
Sorry I incorrectly presented the problem in my previous post :

Since this is the first post in this thread, there is no "previous" post.
The structure of the files is [an ought to be ] like that :
-Function.java

Are you saying that this is in the default package?
-RPN.java
-operand.java

By the Sun-recommended convention, class names should start with an upper-case
letter. (It's in the JLS.
<http://java.sun.com/docs/books/jls/third_edition/html/names.html#6.8>
-Symbol.java
--my_package:
-Stack.java
.................
========================================================

The Stack use the Sybmol class. I got unrecognized symbol Symbol in Stack.
What should i [sic] do ?

Import the Symbol class into your Stack code.

All classes must be referred to by their fully-qualified names, implicitly or
explicitly. If you don't spell out the full name, you have to let the
compiler fill in the missing package specification(s) via the "import" directive.

You cannot import classes from the default package.
 
K

Knute Johnson

Lew said:
Thomas said:
Sorry I incorrectly presented the problem in my previous post :

Since this is the first post in this thread, there is no "previous" post.
The structure of the files is [an ought to be ] like that :
-Function.java

Are you saying that this is in the default package?

If it is it is going to cause him unending grief. He would be better
off with no packages.
 
L

Lew

Knute said:
Lew said:
Thomas said:
Sorry I incorrectly presented the problem in my previous post :

Since this is the first post in this thread, there is no "previous" post.
The structure of the files is [an ought to be ] like that :
-Function.java

Are you saying that this is in the default package?

If it is it is going to cause him unending grief. He would be better
off with no packages.

I disagree. (Not just because the default package is a package and therefore
"no packages" is not actually possible.) Using the default package for any
code involving more that one class or for any purpose other than a
quick-and-dirty test is a Bad Thing. If one is using the default package any
other way, they're better off not using Java at all.

The Sun Java tutorial discusses the use of packages:
<http://java.sun.com/docs/books/tutorial/java/package/index.html>
 
K

Knute Johnson

Lew said:
Knute said:
Lew said:
Thomas wrote:
Sorry I incorrectly presented the problem in my previous post :

Since this is the first post in this thread, there is no "previous"
post.

The structure of the files is [an ought to be ] like that :
-Function.java

Are you saying that this is in the default package?

If it is it is going to cause him unending grief. He would be better
off with no packages.

I disagree. (Not just because the default package is a package and
therefore "no packages" is not actually possible.) Using the default
package for any code involving more that one class or for any purpose
other than a quick-and-dirty test is a Bad Thing. If one is using the
default package any other way, they're better off not using Java at all.

The Sun Java tutorial discusses the use of packages:
<http://java.sun.com/docs/books/tutorial/java/package/index.html>

Obviously I was not clear. What I meant was attempting to mix code from
the default package and another package (which is what it looked like he
was trying to do).
 
R

Roedy Green

s/must/should/

I disagree on that. It is advice similar to washing your hands after
using the toilet before preparing food.

You can also name all your methods m1 m2 etc, but there is no reason
to remind idiots of the option.

This is effectively a classroom, and good practice is mandatory.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Roedy said:
I disagree on that. It is advice similar to washing your hands after
using the toilet before preparing food.

You can also name all your methods m1 m2 etc, but there is no reason
to remind idiots of the option.

This is effectively a classroom, and good practice is mandatory.

Exactly.

It is important to understand the difference between
what is required by the language and what is good
practice.

And therefore it is very bad to confuse the readers
by using must and should as if it means the same.

Arne
 
K

Knute Johnson

Arne said:
Exactly.

It is important to understand the difference between
what is required by the language and what is good
practice.

And therefore it is very bad to confuse the readers
by using must and should as if it means the same.

Arne

Capital first letters of class names in Java is just a convention. It
is neither best nor worst practice.
 
?

=?ISO-8859-1?Q?Arne_Vajh=F8j?=

Knute said:
Capital first letters of class names in Java is just a convention. It
is neither best nor worst practice.

I think there are many that consider following SUN's coding convention
for best practice.

Arne
 

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,994
Messages
2,570,223
Members
46,812
Latest member
GracielaWa

Latest Threads

Top