User Tools

Site Tools


cs257e17:proj2

This is an old revision of the document!


It appears Java 8 has tightened up rules on casting. To fix some of the problems:

Prefer calling superclass methods to accessing the protected instance variables. For example:

   short x, y, z;
   x = super.top();
   super.pop();
   y = super.top();
   super.pop();
   z = (short) x + y;

In dump, trying to output members of the elements array can cause casting errors at runtime. A simple workaround is

Object[] elementsCopy = elements;
for (int i = 0; i <= topIndex; i++) {
   System.out.println((Short) elementsCopy[i]);
}
cs257e17/proj2.1488584359.txt.gz · Last modified: 2017/03/03 17:39 by scarl