Re: Help With TreeMap Warning (Noob?)
Luc The Perverse wrote:
...\Desktop>javac edit_dist.java
Note: edit_dist.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
This warning alerts you that your TreeMap declaration was not generic.
E:\Documents and Settings\Luc\Desktop>javac edit_dist.java -Xlint:unchecked
edit_dist.java:41: warning: [unchecked] unchecked call to put(K,V) as a
member of the raw type java.util.TreeMap
mtm.put(myCurKey, new Integer(min));
^
Here is my code
import java.util.*;
import java.lang.*;
You never need to import java.lang. It is the language itself, so to speak.
import java.math.*;
public class edit_dist{
TreeMap mtm = null;
The initialization to null is both redundant and superfluous.
You did not use a generic type in the Map declaration.
edit_dist(){
You should consider making the constructor public, or omitting it altogether.
mtm = new TreeMap<String, Integer>();
}
By convention, you should name classes with an initial upper-case letter, each
word part capitalized, and eschew underscores: EditDist.
In most scenarios you should prefer to declare variables with the interface
type rather than the concrete class type:
Map<String, Integer> mtm = new TreeMap<String, Integer>();
public static int naive_editDistance(String Source, String Dest){
By convention, you should name variables and methods with an initial
lower-case letter, each word part capitalized, and eschew underscores:
public static int naiveEditDistance( String source, String dest )
..
They call this "camelCase".
- Lew