When a Java method call requires a Class reference

Today I was working with a class that extended the Spring class NamedParameterJdbcDaoSupport, and when I went to use the getNamedParameterJdbcTemplate().queryForObject() method, the third parameter of the method required a Class reference. When you see a method like this that requires a Class reference -- and in my case I needed to use a String class -- you just need to pass it in like this:


To be more specific, my method call looked like this:

getNamedParameterJdbcTemplate().queryForObject(mySqlString, myParamSource, java.lang.String.class)

Any time you see a method call that requires a Class reference, that's all you have to do: pass in the fully-qualified name of the class with the extra .class string at the end.