yes, interfaces are public by default, just like top level classes must be either public or default. Methods in interface are abstract and public by default. and variabels are public static final, you can't explicitly give them other modifiers.
Let me ask you - Class.forName("DatabaseDriver"); is used with out assigning to any variable during DB access, I believe it is getting loaded to memory.
So if at compile time I know the driver name, would it be OK to use DatabaseDriver.class; instead of Class.forName
Thanks! Your correction to my code is appropriate.
I read the api, but couldn't find anywhere .class constant/method, there is something like object.getClass() that can return the Class, but what is this .class. In which class is this defined.
Thanks! Your correction to my code is appropriate.
I read the api, but couldn't find anywhere .class constant/method, there is something like object.getClass() that can return the Class, but what is this .class. In which class is this defined.
Thanks! (A) >>2. By using Class.forName() i.e. Class.forname("Test"). This method call >>returns an Object of type Class. >>i.e. Class testClass = Class.forName("Test");
(B) >>HttpServletRequest.class retrieves the Class object of HttpServletRequest.
I can write from B HttpServletRequest hSR = HttpServletRequest.class and from A hSR = Class.forName("HttpServletRequest") I guess both A) and B) are same because both give a 'Class object'. Sorry, still I don't understand how they are different.
Thanks! (A) >>2. By using Class.forName() i.e. Class.forname("Test"). This method call >>returns an Object of type Class. >>i.e. Class testClass = Class.forName("Test");
(B) >>HttpServletRequest.class retrieves the Class object of HttpServletRequest.
I can write from B HttpServletRequest hSR = HttpServletRequest.class and from A hSR = Class.forName("HttpServletRequest") I guess both A) and B) are same because both give a 'Class object'. Sorry, still I don't understand how they are different.
The code should run properly without throwing any exception.
.equals method takes any object as argument, but if both the argument and the object on which the method was invoked doesn't match, it will return a false.
You can check whether both the objects(argument and the one on which the method was invoked) are same using instanceof operator.