📜  scanner.hasnext() - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:17.859000             🧑  作者: Mango

代码示例2
import java.util.*;  
public class ScannerHasNextExample1 {    
    public static void main(String args[]){       
          //Create Scanner object  
        Scanner scan = new Scanner("Hello World!");  
        //Printing the delimiter used  
        System.out.println("Delimiter:" + scan.delimiter());  
        //Print the Strings  
        while (scan.hasNext()) {  
            System.out.println(scan.next());  
        }  
        //Close the scanner  
        scan.close();  
        }    
}