public String print() { Scanner in = new Scanner(System.in); String sc =in.next(); return sc; }
public static void main(String[] args) {
System.out.println(new t5().print());// call 1st time System.out.println(new t5().print());// if call 2nd time, in.next() will not get any value, throw out NoSuchElementException
public class t5 { public static Scanner in = new Scanner(System.in); public String print() { String sc = in.next(); return sc; }
public static void main(String[] args) {
System.out.println(new t5().print());// call 1st time System.out.println(new t5().print());// if call 2nd time, in.next() will // not get any value, throw out // NoSuchElementException