문제

In my textbook it has us creating abstract data type classes, in this case a Stack. It is based off an array, thus bounded. Here is the part of the code generating the message:

package ch03.stacks;

    public class ArrayStack<T> implements BoundedStackInterface<T> 
    {
  protected final int DEFCAP = 100; // default capacity
  protected T[] stack;              // holds stack elements
  protected int topIndex = -1;      // index of top element in stack

  public ArrayStack() 
  {
    stack = (T[]) new Object[DEFCAP];
  }

  public ArrayStack(int maxSize) 
  {
    stack = (T[]) new Object[maxSize];
  }

I believe the protected T[] stack; part is the issue since it does not have a type set, but that is how it is supposed to be, left generic for the user of the class to specify. Here is the message generated in JGrasp:

Note: ch03\stacks\ArrayStack.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details.

I checked JGrasp help documents but they were of no help.

도움이 되었습니까?

해결책

You need to go to settings->compiler settings->workspace->flags/args, then find the box that says "compile". click in the box. You should be able to type in the text area to the right of the box now. Type "-Xlint:unchecked" in the text area, apply, then save. There is a screenshot on this blog: http://comp2210.blogspot.com/ if you get lost somehow. You'll still get errors when you compile; you can just ignore them and run your program. cheers.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top