{"id":1431,"date":"2022-03-04T05:34:33","date_gmt":"2022-03-04T05:34:33","guid":{"rendered":"https:\/\/mdr.foobrdigital.com\/?p=1431"},"modified":"2022-03-04T05:34:33","modified_gmt":"2022-03-04T05:34:33","slug":"determine-the-class-of-an-object","status":"publish","type":"post","link":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/2022\/03\/04\/determine-the-class-of-an-object\/","title":{"rendered":"Determine the class of an object"},"content":{"rendered":"\n<h4 class=\"wp-block-heading\">Check the class of an object using getClass()<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>class Test1 {\n\/\/ first class\n}\n\nclass Test2 {\n\/\/ second class\n}\n\n\nclass Main {\n  public static void main(String&#91;] args) {\n    \/\/ create objects\n    Test1 obj1 = new Test1();\n    Test2 obj2 = new Test2();\n\n    \/\/ get the class of the object obj1\n    System.out.print(\"The class of obj1 is: \");\n    System.out.println(obj1.getClass());\n\n    \/\/ get the class of the object obj2\n    System.out.print(\"The class of obj2 is: \");\n    System.out.println(obj2.getClass());\n  }\n}<\/code><\/pre>\n\n\n\n<p><strong>Output<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code><samp>The class of obj1 is: class Test1\nThe class of obj2 is: class Test2<\/samp><\/code><\/pre>\n\n\n\n<p>In the above example, we have used the&nbsp;<code>getClass()<\/code>&nbsp;method of the&nbsp;<code>Object<\/code>&nbsp;class to get the class name of the objects&nbsp;<var>obj1<\/var>&nbsp;and&nbsp;<var>obj2<\/var>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Check the class of an object using getClass() Output In the above example, we have used the&nbsp;getClass()&nbsp;method of the&nbsp;Object&nbsp;class to get the class name of the objects&nbsp;obj1&nbsp;and&nbsp;obj2.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[558],"tags":[],"_links":{"self":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1431"}],"collection":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/comments?post=1431"}],"version-history":[{"count":0,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/posts\/1431\/revisions"}],"wp:attachment":[{"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/media?parent=1431"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/categories?post=1431"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mudassirbackup.infinitycodestudio.com\/index.php\/wp-json\/wp\/v2\/tags?post=1431"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}