I have an exercise that gives me x number of inputs and I have to create binary tree with it: https://www.e-olymp.com/en/problems/3096
I have tried this following code
Scanner inp=new Scanner(System.in);
while(true){
String i=inp.next();
int n=Integer.parseInt(i);
thetree.addNode(n,"Boss");
}
But when i click ctrl+z
it gives me errrors like
Exception in thread "main" java.util.NoSuchElementException
at java.util.Scanner.throwFor(Scanner.java:907)
at java.util.Scanner.next(Scanner.java:1416)
at BinaryTree.b1.main(b1.java:41)
How can I get input until ctl+z
just like in c++?