Java examples for Reflection:Class Name
Checks whether a string is a primitive type of java.
//package com.java2s; public class Main { public static void main(String[] argv) { String type = "java2s.com"; System.out.println(isPrimitive(type)); }/*from ww w . j a va 2 s . c o m*/ /** * Checks whether a string is a primitive type of java. * * @param type the type to be checked whether it is a primitive. * @return a boolean denoting whether the given type is a primitive ({@code true}), or not ({@code false}). */ public static boolean isPrimitive(String type) { return (type.equals("boolean") || type.equals("char") || type.equals("double") || type.equals("float") || type.equals("integer") || type.equals("string") || type .equals("boolean")) || (type.equals("Boolean") || type.equals("Char") || type.equals("Double") || type.equals("Float") || type.equals("Integer") || type.equals("String") || type.equals("Boolean") || type.equals("int") || type.equals("long") || type.equals("Int") || type .equals("Long")); } }