How to solve a "Variable 'args' is accessed from within inner class" Java error? -
How to solve a "Variable 'args' is accessed from within inner class" Java error? -
the java class quoted below uses 3 numerical values. want phone call class command line passing different values each time through args variable. when that, "variable 'args' accessed within inner class" java error. what's efficient way - if - accomplish goal?
class userbaserecommenderevaluation { private userbaserecommenderevaluation() {} public static void main(string[] args) throws exception { datamodel model = new filedatamodel(new file("/home/eualin/downloads/ml-100k/final.data")); recommenderbuilder builder = new recommenderbuilder() { @override public recommender buildrecommender(datamodel model) throws tasteexception { usersimilarity similarity = new loglikelihoodsimilarity(model); userneighborhood neighborhood = new nearestnuserneighborhood(2, similarity, model); homecoming new genericuserbasedrecommender(model, neighborhood, similarity); } }; recommenderirstatsevaluator evaluator = new genericrecommenderirstatsevaluator(); irstatistics stats = evaluator.evaluate(builder, null, model, null, 1, genericrecommenderirstatsevaluator.choose_threshold, 1); } }
update: farther step, how create above function work within loop assigns different value each of these parameters? in case, maintain in mind there need deal error handling otherwise execution terminated unexpectedly of combinations not 'appropriate'.
if wishing access values args
parameter, specify final
. illustration below compile , run nicely:
public class innerclassexample { public static void main(final string[] args) { runnable runnable = new runnable() { @override public void run() { (int = 0; < args.length; i++) { system.out.println(args[i]); } } }; runnable.run(); } }
this prints:
1 2 3
java syntax-error
Comments
Post a Comment