Double % formatting question for printf in Java

前端 未结 4 1335
死守一世寂寞
死守一世寂寞 2020-12-14 15:46

%s is a string in printf, and %d is a decimal I thought...yet when putting in

writer.printf(\"%d dollars is the balance of %s\\r\\         


        
4条回答
  •  一生所求
    2020-12-14 16:31

    Following is the list of conversion characters that you may use in the printf:

    %d – for signed decimal integer
    
    %f – for the floating point
    
    %o – octal number
    
    %c – for a character
    
    %s – a string
    
    %i – use for integer base 10
    
    %u – for unsigned decimal number
    
    %x – hexadecimal number
    
    %% – for writing % (percentage)
    
    %n – for new line = \n
    

提交回复
热议问题