Olá, existe alguma diferença entre usar o printf e o format?
Exemplo 01:
float nota = 5.3f
System.out.printf ("Sua nota: %.2f", nota)
Exemplo 02:
float nota = 5.3f
System.out.format ("Sua nota: %.2f", nota)
Olá, existe alguma diferença entre usar o printf e o format?
Exemplo 01:
float nota = 5.3f
System.out.printf ("Sua nota: %.2f", nota)
Exemplo 02:
float nota = 5.3f
System.out.format ("Sua nota: %.2f", nota)
Não existe diferença, segundo consta na documentação.
A convenience method to write a formatted string to this output stream using the specified format string and arguments.
An invocation of this method of the form out.printf(format, args) behaves in exactly the same way as the invocation
out.format(format, args)