Closed JackLovel closed 4 years ago
When I run BinarySearchST.java
in win10 console , happen a Uncheck
problem.
BinarySearchST.java:82: Warning: [unchecked] unchecked conversion
keys = (Key[]) new Comparable[capacity];
^
need: Key[]
find: Comparable[]
Key is a type variable:
The Key extension has declared Comparable < Key > in the class BinarySearchST
BinarySearchST.java:83: Warning: [unchecked] unchecked conversion
vals = (Value[]) new Object[capacity];
^
need: Value[]
find: Object[]
Value is a type variable:
Value extends Object declared in the class BinarySearchST
BinarySearchST.java:90: Warning: [unchecked] unchecked conversion
Key[] tempk = (Key[]) new Comparable[capacity];
^
need: Key[]
find: Comparable[]
Key is a type variable
The Key extension has declared Comparable < Key > in the class BinarySearchST
BinarySearchST.java:91: Warning: [unchecked] unchecked conversion
Value[] tempv = (Value[]) new Object[capacity];
^
need: Value[]
find: Object[]
Value is a type variable:
Value extends Object declared in the class BinarySearchST
4 warnings
Added @SuppressWarnings("unchecked")
before the following two functions:
public BinarySearchST(int capacity) {...}
private void resize(int capacity) {...}
I run this java file in win10 windows console , but I can't stop input;
so I add this code
if(key.equals("q")) break;
that can stop input and output result;