zoukankan      html  css  js  c++  java
  • 类似C语言格式化输出

    java se5引入的format方法可以用于PrintStream或PrintWriter对象,format方法模仿自C的printf(),

    如果你比较怀旧的话,也可以用printf()。

    package example;
    
    
    public class Test  {
        public static void main(String[] args){
            int x=5;
            double y=5.332542;
            System.out.println("Row1:["+x+" "+y+"]");
            System.out.format("Row1:[%d %f]
    ",x,y);
            System.out.printf("Row1:[%d %f]
    ",x,y);
            /*output:
             *Row1:[5 5.332542]
             *Row1:[5 5.332542]
             *Row1:[5 5.332542]
             * 
             */
            
        }
        
    }
  • 相关阅读:
    Vue
    linux-----docker
    linux基础
    Flask基础
    websocket
    css
    Mysql数据库基础
    IO多路复用
    线程和协程
    sh_02_del关键字
  • 原文地址:https://www.cnblogs.com/xurui1995/p/5299048.html
Copyright © 2011-2022 走看看