0

I tried to print integers by using this format: int x=7 --> output = 07 so I have write this code:

public class test{
public static void main(String[] args){
int x=7;
System.out.printf("your converted number = %02d",x);
}
}

but the OUTPUT in Netbeans 11.2 IDE is :

your converted number = ??

how can I fix this error in my own Netbeans version?

Nameless
  • 147
  • 11
  • That's very unexpected. Is that copy-and-pasted code, or did you re-type it? – Daniel May 12 '20 at 17:37
  • Im new to stackoverflow so thats why I was not write my problem in correctly way...sorry – Nameless May 12 '20 at 17:40
  • Hi, Welcome to SO. Please check [How to Ask](https://stackoverflow.com/help/how-to-ask) – kadamb May 12 '20 at 17:42
  • No worries. I'm asking because I want to make sure we're looking at the *exact* code that is causing the problem. Please use copy and paste, both for the code and for the output. For the record, when I run the code in your quest, I get the output `your converted number = 07`. – Daniel May 12 '20 at 17:43
  • Yes...If you copy this code in your Netbeans 11.2 IDE you will see the same output – Nameless May 12 '20 at 17:46
  • I don't use Netbeans, sorry. I use IntelliJ IDEA. – Daniel May 12 '20 at 18:08
  • 1
    Does this answer your question? [String.format prints 'question mark' as output](https://stackoverflow.com/questions/30049590/string-format-prints-question-mark-as-output) – Daniel May 12 '20 at 18:09
  • Unfortunately no...because thats for Eclipse IDE – Nameless May 12 '20 at 18:47

1 Answers1

1

I think it may have to do with internationalization setting for your locale. See: String.format prints 'question mark' as output

JohannesB
  • 2,214
  • 1
  • 11
  • 18
  • Thanks for the answer but that link''s answer was for Eclipse IDE and my IDE is Netbeans – Nameless May 12 '20 at 18:47
  • See this answer for Netbeans console encoding configuration https://stackoverflow.com/a/27848261/6250649 – JohannesB May 12 '20 at 19:15
  • Still not worked in my IDE ...can you please download netbeans 11.2 and test my code ?Maybe after that you can give me more clear answere – Nameless May 12 '20 at 19:33
  • I am not even going to try because I know the results depend on your/my computer's operating system country and language (locale) settings that conflict on your setup but will work fine for countries using Latin alphabet and English codepage settings, see: https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html – JohannesB May 12 '20 at 19:52