Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / July 2006

Tip: Looking for answers? Try searching our database.

What is <E>?

Thread view: 
Redbeard - 05 Jul 2006 15:36 GMT
I recently upgraded my SDK to 1.5 and was looking at the documentation
of the Vector class, which I have used in a class that I'm updating.  I
noticed in 1.5 that it now has the symbol <E> after the name.  I also
noticed that methods like add() now have an E parameter instead of an
Object parameter.

Java 1.3
public boolean add(Object o)

Java 1.5
public boolean add(E o)

But when I click on the link for E, it simply takes me back to the top
of the page.  I tried this with a couple other related classes (i.e.
Stack) and got the same results.

What the heck is this E all about?  Enums?  How would this affect my
code?

Thanks Tom
Oliver Wong - 05 Jul 2006 15:39 GMT
>I recently upgraded my SDK to 1.5 and was looking at the documentation
> of the Vector class, which I have used in a class that I'm updating.  I
[quoted text clipped - 14 lines]
> What the heck is this E all about?  Enums?  How would this affect my
> code?

   Not enums; generics. See
http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html

   - Oliver
Redbeard - 05 Jul 2006 17:08 GMT
> >I recently upgraded my SDK to 1.5 and was looking at the documentation
> > of the Vector class, which I have used in a class that I'm updating.  I
[quoted text clipped - 19 lines]
>
>     - Oliver

Thanks!  I've heard of generics, but know little about them.  Looks
like I've got some reading to do.

One of my applets was specifically written to Java 1.1 standards to
avoid the need for the plug-in.  Is this going to break now that 1.5 is
out?
Oliver Wong - 05 Jul 2006 17:55 GMT
>> See
>> http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html
[quoted text clipped - 5 lines]
> avoid the need for the plug-in.  Is this going to break now that 1.5 is
> out?

   I don't understand the question. Whatever version of Java you write to,
you still need SOME Java plugin to run your applet. This document might
answer your question:
http://java.sun.com/javase/technologies/compatibility.jsp

   - Oliver
John W. Kennedy - 05 Jul 2006 18:35 GMT
>>> See
>>> http://java.sun.com/j2se/1.5.0/docs/guide/language/generics.html
[quoted text clipped - 10 lines]
> might answer your question:
> http://java.sun.com/javase/technologies/compatibility.jsp

/The/ Java Plug-In is a piece of Sun software that comes with Java,
which extends browsers (using the standard browser extension mechanism,
except on Internet Explorer, where it has to use Microsoft's proprietary
mechanism instead) to run Java. It was developed many years ago because
Netscape was being slow updating their built-in Java support, and
because Microsoft was deliberately putting landmines in theirs.

There was a time when you did not need a Java Plug-In; you just needed a
Java and a Java-supporting browser.

Signature

John W. Kennedy
"The blind rulers of Logres
Nourished the land on a fallacy of rational virtue."
  -- Charles Williams.  "Taliessin through Logres: Prelude"

Redbeard - 06 Jul 2006 04:05 GMT
>     I don't understand the question. Whatever version of Java you write to,
> you still need SOME Java plugin to run your applet. This document might
> answer your question:
> http://java.sun.com/javase/technologies/compatibility.jsp
>
>     - Oliver
As others have mentioned, this was not always the case.  Back when I
originally wrote the applet that I'm concerned about, both Netscape and
Microsoft still had their own built-in Java 1.1 JVM.  Dial-up was still
the norm and getting non-technical people to download the JVM and
plugin was something to avoid.  And as I mentioned in my other post,
this applet is educational in nature, and many schools are still using
ancient hardware and software.  I just retired a P133 at my school.
grasp06110 - 05 Jul 2006 23:03 GMT
> One of my applets was specifically written to Java 1.1 standards to
> avoid the need for the plug-in.  Is this going to break now that 1.5 is
> out?

I have been told that Java 1.5 byte code will run in older version of
the JVM.  Not sure of the details beyond that.  

John
Redbeard - 06 Jul 2006 03:59 GMT
> > One of my applets was specifically written to Java 1.1 standards to
> > avoid the need for the plug-in.  Is this going to break now that 1.5 is
[quoted text clipped - 4 lines]
>
> John
I'm not worried about that, as much as I'm worried about my existing
Java 1.1 bytecode running in the 1.5 JVM which apparently doesn't have
the older version of the Vector class.  I wrote the applet several
years ago when IE came with its own JVM.  The applet is educational,
and many schools are still using out-of-date hardware with older
operating systems like Win98, and the older browsers that come with
them.  Of course, there are also some, like mine, that have up-to-date
hardware and software.  So I also need the applet to work on those
machines too.

BTW, I've probably confused people by switching questions in
mid-thread.  I wasn't thinking of this applet when I first asked the
question.  But the answer to my original question led to this concern.

Also, even though I'm not planning on working on this particular
applet, I may create a new one and will want to reuse some of the
components from the old one and keep it written to Java 1.1 standards.

FWIW, it appears that the older version would be Vector<Object> in the
new system.  Maybe Vector and Vector<Object> are treated as the same
thing by the JVM.
Hendrik Maryns - 06 Jul 2006 08:47 GMT
Redbeard schreef:
> FWIW, it appears that the older version would be Vector<Object> in the
> new system.  Maybe Vector and Vector<Object> are treated as the same
> thing by the JVM.

Not entirely, but you can still simply use Vector without any generic
argument and ignore the warnings, if you want.

(If I really needed a Vector<Object>, I would rethink my design)

H.
- --
Hendrik Maryns

==================
http://aouw.org
Ask smart questions, get good answers:
http://www.catb.org/~esr/faqs/smart-questions.html
Oliver Wong - 06 Jul 2006 15:35 GMT
>> > One of my applets was specifically written to Java 1.1 standards to
>> > avoid the need for the plug-in.  Is this going to break now that 1.5 is
[quoted text clipped - 13 lines]
> hardware and software.  So I also need the applet to work on those
> machines too.

   IE's JVM is a special case, because it doesn't actually implement the
Java Standard. Basically, if you use MSJVM, all bets are off.

   So ignoring MSJVM for now, 1.1 code should, for the most part, work with
1.5. In particular, if you don't use generics, your code will still run
fine. The generics information is only for compile time checking, and that
information doesn't even appear in the class files (google for Java Type
Erasure for more details).

   The only thing is you'll get warnings with a 1.5 compiler. They're
trying to encourage you to use generics. But you can ignore those warnings
(or disable them completely).

> FWIW, it appears that the older version would be Vector<Object> in the
> new system.  Maybe Vector and Vector<Object> are treated as the same
> thing by the JVM.

   There was a discussion a while ago; not sure if it's this newsgroup or
comp.lang.java.programmer, but the conclusion was that Vector, Vector<?> and
Vector<Object> are not exactly interchangeable, in some obscure corner
cases. If you want to use the "old" Vector, just use Vector (without any
type qualifiers), and live with the warning until you understand generics
better. It's better than putting in the wrong type qualifier and then
getting strange compile errors that you can't untangle.

   - Oliver
Daniel Dyer - 06 Jul 2006 15:41 GMT
>> FWIW, it appears that the older version would be Vector<Object> in the
>> new system.  Maybe Vector and Vector<Object> are treated as the same
[quoted text clipped - 8 lines]
> type qualifier and then getting strange compile errors that you can't  
> untangle.

If you want to target 1.1 you will have to omit the type qualifier beause  
you can't set the compiler target to 1.1 and the source verion to 1.5 with  
javac.

Dan.

Signature

Daniel Dyer
http://www.dandyer.co.uk



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.