Let's look at those three lines:
1. Declares an array of Class objects and initializes it with two elements, which are both String.class (the Class object of class
String).
2. Uses the reflection API to find a method named "getCost" which takes two strings as arguments. In other words, the class that "myclass" refers to must have a method that looks like this:
public ... getCost(String arg1, String arg2)
(the return type is not specified).
3. Creates a new Object array with two strings, with the values "chennai" and "goa".
Note: It is
never necessary to create a new String object from a literal like is done in line 3. This should have been written like this:
Object[] args = new Object[] { "chennai", "goa" };
Shorter, easier to read and doesn't create unnecessary String objects.