Get the Category name from the post id in wordpress

Code for getting the category name from the post_id.

<?php
$category = get_the_category($post->ID); 
echo $category[0]->cat_name;
?>
Advertisements

Calling a Method in Java

Here is the sample Java code that demonstrate how to call a method that is available in a non-main Class.

File:demo1.java

class dem
{
void get()
{
System.out.println(“Hi! Welcome”);
}
void show()
{
System.out.println(“Thanks”);
}
}
class demo1
{
public static void main(String a[])
{
dem d=new dem();
d.get();
d.show();
}
}

Here is the Output:

Hi! Welcome

Thanks

Share your comments and queries