mardi 19 mai 2015

Cannot find symbol in Locale class

I'm having some trouble with building my code, and it stems from objects from the Locale class in my tests. Here is a quick mock-up of how my test class looks like:

import java.util.Locale;

public class myTest {

    public class test1() {
        Locale locale = new Locale("");
        locale = Locale.getDefault(Locale.Category.DISPLAY);
        ....
    }

    public class test2() {
        Locale locale = new Locale("");
        locale = Locale.forLanguageTag("testController1");
        ....
    }
}

Now, for the first test, I get there error:

[6376,41] cannot find symbol
[ERROR] symbol  : variable Category
[ERROR] location: class java.util.Locale

And for the second test, I get:

[6675,23] cannot find symbol
[ERROR] symbol  : method forLanguageTag(java.lang.String)
[ERROR] location: class java.util.Locale

I'm not sure why I am getting these errors. In the first code, the locale object was instantiated as Locale local = Locale.forLanguageTag("testController1");, and I thought that was the issue, but I guess not.

EDIT: Could somebody tell me why this question was voted down? I did my research, and most answers point me to an object that is out of scope. I pretty much made sure my object is in scope, so I am still unclear.

Aucun commentaire:

Enregistrer un commentaire