import magic

R

Roedy Green

I understand that I import classes in Java so that it can figure out
if the method signatures on the calls match those off the imported
callees. IT need help finding the packages of the class names I use.

Why is it that if I write:

Font temp = x.getFont();
y.setFont( temp );

I need to import java.awt.Font;

but If I write:

y.setFont( x.getFont() );

I don't.

It seem on first breath they are equally difficult problems.
So how come Java needs help with import on the first but not the
second.


It seems odd that some trivial detail as to whether you use a temp
variable somewhere, e.g. added for debugging, that it should any
bearing on something so overarching as imports. I am still using the
exact same classes!

I hate the way you have to keep putting them in and taking them out.



--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
T

Tim Miller

Roedy said:
I understand that I import classes in Java so that it can figure out
if the method signatures on the calls match those off the imported
callees. IT need help finding the packages of the class names I use.

Why is it that if I write:

Font temp = x.getFont();
y.setFont( temp );

I need to import java.awt.Font;

but If I write:

y.setFont( x.getFont() );

I don't.
Because you don't reference the identifier "Font" in the second
statement. While instances of "Font" are still being used, the
compiler can detect that x.getFont() returns an instance of
java.awt.Font, and y.setFont(..) takes as a parameter
java.awt.Font. The package name is already apparent from the
method signatures, so you don't need to import them. In the first
statement, however, "Font temp =.." could be referring to a class
called "Font" from different packages.
 
R

Roedy Green

Because you don't reference the identifier "Font" in the second
statement. While instances of "Font" are still being used, the
compiler can detect that x.getFont() returns an instance of
java.awt.Font, and y.setFont(..) takes as a parameter
java.awt.Font. The package name is already apparent from the
method signatures, so you don't need to import them. In the first
statement, however, "Font temp =.." could be referring to a class
called "Font" from different packages.

Many thanks. that has been as itch I have never got around to
scratching since Java 1.0.


--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
B

Boudewijn Dijkstra

Roedy Green said:
[...about imports...]

I hate the way you have to keep putting them in and taking them out.

Once you have put one in, you can leave it there.
 
I

IchBin

Boudewijn said:
Roedy Green said:
[...about imports...]

I hate the way you have to keep putting them in and taking them out.

Once you have put one in, you can leave it there.
For Eclipse just use menu item Source \ Organize Imports

or [Ctrl Shift O]

--


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
__________________________________________________________________________

' If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
R

Roedy Green

You could stop using Eclipse. : o )

It did a very nasty bad to me today totally scrambling my program
moving all implementation of the same method next to each other and
tossing out some declarations. that method reorder thing is pretty
darn dangerous.

Is it just me or do eclipse people never split the screen to look at
two parts of the same program at once or two versions of a similar
program side by side. It can rapidly flip, but I like to see.

Also I miss being able to sort without leaving the IDE, just select
some the column and range with the mouse to reorder static init data
etc.

I was overwhelmed looking at the plugins available. I had not the
vaguest clue what most of them were for.

There is so much arcane vocabulary to learn.


I wish plugin descriptions were not just for people who wanted a thing
but to but also for the novice to know roughly what it is for. When
all you see in an acronym you have no idea of whether to pursue the
matter further.


--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
I

IchBin

Roedy said:
I wish plugin descriptions were not just for people who wanted a thing
but to but also for the novice to know roughly what it is for. When
all you see in an acronym you have no idea of whether to pursue the
matter further.
This is where the learning curve comes in, at least for me. This maybe
the best place to start http://www.eclipse.org/projects

I think that you would be interested in the following

Tools Project (CDT) C/C++ Development Tools
http://www.eclipse.org/cdt

Technology Project (WTP) Eclipse Web Tools Platform
http://www.eclipse.org/webtools

Tools Project (VE) Visual Editor
http://www.eclipse.org/webtools

Tools Project (UML2) is an EMF-based implementation of the UML
http://www.eclipse.org/webtools

Not sure if you would be interested in SWT or compare it to AWT\SWING.
Also PDE, the Eclipse plugin development.

You just have to be aware of the prerequisites with VE, WTP and UML2.



--


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
__________________________________________________________________________

' If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
I

IchBin

IchBin said:
This is where the learning curve comes in, at least for me. This maybe
the best place to start http://www.eclipse.org/projects

I think that you would be interested in the following

Tools Project (CDT) C/C++ Development Tools
http://www.eclipse.org/cdt

Technology Project (WTP) Eclipse Web Tools Platform
http://www.eclipse.org/webtools

Tools Project (VE) Visual Editor
http://www.eclipse.org/webtools

Tools Project (UML2) is an EMF-based implementation of the UML
http://www.eclipse.org/webtools

Not sure if you would be interested in SWT or compare it to AWT\SWING.
Also PDE, the Eclipse plugin development.

You just have to be aware of the prerequisites with VE, WTP and UML2.
Sorry..

Tools Project (VE) Visual Editor
http://www.eclipse.org/vep/

Tools Project (UML2) is an EMF-based implementation of the UML
http://www.eclipse.org/uml2/


--


Thanks in Advance...
IchBin, Pocono Lake, Pa, USA
__________________________________________________________________________

' If there is one, Knowledge is the "Fountain of Youth"'
-William E. Taylor, Regular Guy (1952-)
 
H

Henk van Voorthuijsen

Is it just me or do eclipse people never split the screen to look at
two parts of the same program at once or two versions of a similar
program side by side. It can rapidly flip, but I like to see.

You can use the compare view to compare two compilation elements:
In the package or outline view select two method names. The context menu on
the selection hase a "Compare With/ Other Element..." item. This works
across files as well.
 
D

david

Roedy Green schrieben:
[...about imports...]
I hate the way you have to keep putting them in and taking them out.

Boudewijn said:
Once you have put one in, you can leave it there.


I prefer to use specific imports (e.g. "import java.io.File") instead
of wildcard imports ("import java.io.*"). This makes my compilations
faster (at least in theory). It also forces me to list all of the
classes used in my code, which tends to be of some help when I (or the
other guy who has the joy of maintaining my code) track the classes
down.

It also tends to alleviate problems of using twin class names that
appear in more than one package, especially if my code uses a lot of
third-party packages.

-drt
 
J

Joan

Roedy Green said:
It did a very nasty bad to me today totally scrambling my program
moving all implementation of the same method next to each other and
tossing out some declarations. that method reorder thing is pretty
darn dangerous.

So read the fucking warning before you fucking click on it.
 
R

Roedy Green

So read the fucking warning before you fucking click on it.

The UI is designed so that this dangerous feature is right next to
"correct indentation" which I use routinely. It is very easy to hit
"sort members" by mistake. This is why in my tips section I advise
against removing the warning even if you know the danger.

I think Eclipse itself should refuse to invoke it unless it has a
clean compile.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
R

Roedy Green

I prefer to use specific imports (e.g. "import java.io.File") instead
of wildcard imports ("import java.io.*"). This makes my compilations
faster (at least in theory). It also forces me to list all of the
classes used in my code, which tends to be of some help when I (or the
other guy who has the joy of maintaining my code) track the classes
down.

it also helps when it comes time to build a zip or jar.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 
T

Tor Iver Wilhelmsen

Roedy Green said:
it also helps when it comes time to build a zip or jar.

Why? The dependency analysis should only concern itself with classes
actually used; imports are only used by the compiler, all types are
fully qualified in the class file. E.g. if you import com.foo.* and
only use the class Fie from that package, only com.foo.Fie will be
considered a dependency.
 
R

Roedy Green

Why? The dependency analysis should only concern itself with classes
actually used; imports are only used by the compiler, all types are
fully qualified in the class file. E.g. if you import com.foo.* and
only use the class Fie from that package, only com.foo.Fie will be
considered a dependency.

if you are bundling up source code to give to someone, you have to
figure out what to include. One starting point is looking at the
aggregate imports of classes you wrote.

--
Bush crime family lost/embezzled $3 trillion from Pentagon.
Complicit Bush-friendly media keeps mum. Rumsfeld confesses on video.
http://www.infowars.com/articles/us/mckinney_grills_rumsfeld.htm

Canadian Mind Products, Roedy Green.
See http://mindprod.com/iraq.html photos of Bush's war crimes
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top