Code example for Scanner

Methods: hasNextIntnextInt

0
	 * Read int. 
	 *  
	 * @return the int 
	 */ 
	protected int readInt() { 
		if (!sc.hasNextInt()) {
			throw new IllegalArgumentException();
		} 
		int num = sc.nextInt();
		return num;
	} 
 
	/** 
	 * Read char. 
	 *  
	 * @return the char 
	 */ 
	protected char readChar() { 
		char ch = sc.findInLine(".").charAt(0);
 
Connect your IDE to all the code out there  Get Codota for Java