java - Scanner delimiter passed with parameter? -
i need parse input-line character character, , done through several methods. char char, using usedelimiter(""). question is: need set delimiter in every method? or plenty once, @ beginning?
e.g.
void start() { scanner in = new scanner(system.in); in.usedelimiter(""); char first = in.next(); readsecond(in); ... } void readsecond(scanner in) { //in.usedelimiter(""); <-- needed? char sec = in.next(); ... }
example input: a5c*vd
thanks !
you wouldn't have set every time if declare , initialize scanner object in class body methods in. if initialize scanner in each method, think have set delimiter in each method body.
java java.util.scanner delimiter
No comments:
Post a Comment