STeN
STeN

Reputation: 6268

Create Formatter object fails

I have following simple code snippet:

StringBuilder sb = new StringBuilder();
Locale l = Locale.getDefault();         
Formatter formatter = new Formatter( sb, l );

In documentation I see that the Formatter has following constructor:

Formatter(Appendable a, Locale l)

So why the compiler tells me there is an error in my code:

The constructor Formatter(StringBuilder, Locale) is undefined

Sorry for such simple questions...

BR

STeN


Answer (added later): I was by mistake using the android.text.format.Formatter, which was automatically imported by Eclipse instead of java.util.Formatter.

Upvotes: 1

Views: 332

Answers (1)

Ted Hopp
Ted Hopp

Reputation: 234847

That code works for me. Do you have an import problem? There are three Formatter classes in Android: java.util, android.text.formatting, and android.util.logging.

Upvotes: 2

Related Questions