“scanner.hasnext ()” Code-Antworten

Was macht scan.hasnext tun

The hasNext() method checks if the Scanner has another token in its input. 
A Scanner breaks its input into tokens using a delimiter pattern, 
which matches whitespace by default. 
That is, hasNext() checks the input and returns true if it has another non-whitespace character.
Homely Heron

scanner.hasnext ()

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();  
        }    
}  
Jolly Jellyfish

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen