Creating objects to classes

An object is an instance of a class. This example demonstrates of how to create an object for a class in Java.

class MyClass
{
public void print()
{
System.out.println("I am in print() of MyClass");
}
}
class ObjectDemo
{
public static void main(String args[])
{
MyClass m=new MyClass();
m.print();
}
}
MyClass : The class for which object is created.
print() : Prints the output.
m : Object of type MyClass.
new : Keyword that creates the object.