“Scanner.hasNext ()” Código de respuesta

¿Qué hace Scan.hasnext?

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

Explore las respuestas de código populares por idioma

Explorar otros lenguajes de código