title: typeof in Java 8
body: <p>If we want to check the datatype of variable in javascript, we can use <code>typeof</code> operator .</p>
  
  <h2>Consider this snippet</h2>
  
  <pre><code>var c = 'str' ;
  console.log(typeof(c)); // string
  c = 123 ;
  console.log(typeof(c)); // number
  c =  {} ;
  console.log(typeof(c)) ; // object
  </code></pre>
  
  <p>I want to achieve the same functionality in <code>Java 8</code> . Java does not have typeof operator but there's the <code>instanceof</code> operator to check the types.</p>
  
  <pre><code>System.out.println("str" instanceof String);  // true 
  
  Integer a  = 12 ;
  System.out.println(a instanceof Integer);
  
  
  Float f = 12.3f
  System.out.println(f instanceof Float); // true
  </code></pre>
  
  <p>Can we do any better ? Plus <code>instanceof</code> does not support primitive types .</p>
  
  <p>Is there any approaches in <code>java 8</code> ? Any relevant approaches will be appreciated. </p>