Java.io.PrintWriter.print float() 方法


Java.io.PrintWriter.print float() 方法

package com.codingdict;



import java.io.*;



public class PrintWriterDemo {



   public static void main(String[] args) {

      float f = 1234.56f;



      // create a new writer

      PrintWriter pw = new PrintWriter(System.out);



      // print float

      pw.print(f);



      // change the line

      pw.println();



      // print another float

      pw.print(1.23f);



      // flush the writer

      pw.flush();

   }

}