aspose file tools*
The moose likes IDEs, Version Control and other tools and the fly likes Dynamic Data Types in Eclipse Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Dynamic Data Types in Eclipse" Watch "Dynamic Data Types in Eclipse" New topic
Author

Dynamic Data Types in Eclipse

Jeffmeme Wrightmeme
Greenhorn

Joined: Jan 14, 2005
Posts: 3
All righty. I'm fairly new to Java, but I've had extensive experience in PHP and C++.
I forget the exact name for what I'm trying to do, but what it amounts to is this. Pretend you have a Linked List class and you dont want to specify what it's a list OF (at run-time you might want a list of strings or ints or chars or whatever). The way I was told I should do this was as follows:

public class Jeff<E>
{
E data;
public Jeff(E data)
{
this.data = data;
System.out.println("test: "+data);
}

public static void main(String[] args)
{
Jeff<Double> j = new Jeff(3);
}
}

where the <E> at the end of the class declaration signifies that you will tell it what data type you want later.

This is all well and good when I use a good, old-fashioned commandline compiler. When I put it into Eclipse, however, it underlines "Jeff<E>" in red and says "Syntax error on tokens, delete these tokens."

Does anyone know what would cause this, or how to fix it? As I say, the exact same code compiles fine using a command-line compiler.

Thanks a bunch in advance!!

P.S. Sorry 'bout the 'me's on my name, but Jeff Wright was taken...

[ January 14, 2005: Message edited by: Jeffmeme Wrightmeme ]

[ EJFH: Fixed ersatz HTML tags. ]
[ January 14, 2005: Message edited by: Ernest Friedman-Hill ]
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
I guess you work with Java 5 and use generics?

Then you need the latest milestone build of Eclipse 3.1 - earlier versions don't support anything above JDK 1.4.


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Jeffmeme Wrightmeme
Greenhorn

Joined: Jan 14, 2005
Posts: 3
awesome, thanks. I'll go download that and see if that fixes my problem.

Thanks again.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
You will also need to adjust the compliance setting of the Eclipse compiler, btw.
Jeffmeme Wrightmeme
Greenhorn

Joined: Jan 14, 2005
Posts: 3
How do I do that?
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
From memory it must be somewhere along the lines of "Windows/Preferences/Java/Compiler/Compliance".
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30758
    
156

Jeff,
On the display name, you can actually get "Jeff Wright." Our system lets you have the display name you want even if someone else has it. It just doesn't let you have the same login name.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamic Data Types in Eclipse