Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package O2DataTypesAndVar.MoreExercise;
- import java.util.Scanner;
- public class Ex01DataTypeFinder {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- while (!scanner.hasNext("END") ) {
- System.out.println(
- scanner.hasNextInt() ? scanner.nextInt() + " is integer type" :
- scanner.hasNextFloat() ? scanner.nextFloat() + " is floating point type" :
- scanner.hasNextBoolean() ? scanner.nextBoolean() + " is boolean type" :
- scanner.hasNextLine() && scanner.toString().length() != 1 ? scanner.next() + " is string type" :
- scanner.toString() + " is character type"
- );
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment