Skip to main content



      Home
Home » Language IDEs » Java Development Tools (JDT) » How to change default generic type from E to T(Code Assist keeps autofilling generic type with E)
How to change default generic type from E to T [message #1826823] Fri, 01 May 2020 11:36 Go to next message
Eclipse UserFriend
I've been working a lot recently with object-oriented programming in java on Eclipse, and the preferred name for generic types used in my CS class is "T", however, whenever code assist suggests a name it uses "E" as a name instead. Is there a way to change this default generic name, from E to T in preferences? I want this to apply to all future projects in Eclipse. If so can someone please direct me through it? Thank you.
Re: How to change default generic type from E to T [message #1826845 is a reply to message #1826823] Sat, 02 May 2020 03:58 Go to previous messageGo to next message
Eclipse UserFriend
Hi

I think that you will find it defaults to the spelling in the declaration so to change a Collection you would need Oracle to change from Collection<E> to Collection<T>. For your own classes you have a free choice.

Many authors pick a slightly mnemonic parameter letter, so the original design was probably E for Collection-of-Element. By changing to T you subvert that clue. Of course if Thingy is very important in your application T might be sensible for a Collection-of-Thingy.

Regards

Ed Willink
Re: How to change default generic type from E to T [message #1826846 is a reply to message #1826845] Sat, 02 May 2020 06:14 Go to previous message
Eclipse UserFriend
Let me add that using the same name for all type parameters can also cause a lot of confusion, like in compile errors of the kind "Type mismatch: cannot convert from T to T". We frequently get bug reports with examples that simply cannot be deciphered until we assign unique names to all type parameters. Some people even forget that there is no rule in the Java grammar saying that type parameters must have single letter names ;p
The <T> convention is a bit like naming all classes C, all methods m, and all arguments arg.
Previous Topic:The import org.eclipse cannot be resolved
Next Topic:JDT Core code assist
Goto Forum:
  


Current Time: Sun Aug 31 00:23:33 EDT 2025

Powered by FUDForum. Page generated in 0.02853 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top