1. Not finding help here? Sign up for a free 30min tutor trial with Chegg Tutors
    Dismiss Notice
Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Java generic array list

  1. Aug 14, 2011 #1
    I am getting compilation errors in the following segment of my code:

    _underlyingStorage was declared in the following way: private T[] _underlyingStorage = (T[]) new Object[128];

    public T next() {
    _currentIndex++;
    if(_underlyingStorage[_currentIndex] == _underlyingStorage[_numElements-1])
    _underlyingStorage[_currentIndex] = _underlyingStorage[0];
    return _underlyingStorage[_currentIndex];
    }

    the error I'm getting makes no sense to me.. it says that T does not match T. what's happening here?
     
  2. jcsd
  3. Aug 15, 2011 #2
    Where are you getting the error at? I entered everything you had into a class, but I'm not getting any error.
     
  4. Aug 15, 2011 #3

    Hurkyl

    User Avatar
    Staff Emeritus
    Science Advisor
    Gold Member

    Errors reported by the compiler and the runtime are usually very precisely worded, containing a very literal description of a problem in your program and where that problem occurs.

    If you aren't yet experienced enough to extract this information from an error, you should copy it verbatim when you ask for others to help. (also, there's probably a line number involved. It would help if you point out which line of your code it refers to)
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Java generic array list
  1. Arrays in Java (Replies: 3)

  2. Java class Arrays (Replies: 1)

Loading...