I am reading the Deitel book and it says there is a key sequence CTRL z that terminates the Scanner Input.so I wrote a similar code in NetBeans IDE(a code similar to the Deitel's book)
        Scanner y = new Scanner(System.in);
        String g;
        while(y.hasNext())
        {
            g = y.nextLine();
            System.out.println(g);
        }
but as I press CTRL-z after entering some input,nothing happens. Does such a thing exist in java(EOF key sequence)?I have also visited the page How to terminate Scanner when input is complete? but the suggested codes didn't work for me.
 
     
     
     
    