5 Replies Latest reply on Apr 9, 2010 4:15 AM by 843793

    Removing need for cast with generic possible?


      I've had success with generics in some areas, but not this and wondered if and how you can remove the need to cast in the following example:
      public abstract class Record {
           private String description = "Some Description";
           public String getDescription() {
                return description;
      public abstract class RecordDiskFile extends Record { 
           private String imagePath = "Some Image Path";     
           public String getImagePath() {
                return imagePath;
      public class Item extends RecordDiskFile {
      Record item = new Item();
      item.getDescription();    ----> works
      item.getImagePath();     -----> fails and needs ((RecordDiskFile) item).getImagePath();
      Thanks, Len