Example :1>When JVM calls the Main Method, it Executes it as Thread.
Class DEMO(){
public static void main(String args[]){
S.o.p("sekhar");
}
}
Class DEMO2(){
Public static void main(String args[]){
DEMO.main("some argument");
}
}
2>When We call the main Method it Executes it as Function.
Note : We can call main Method of a Class by Passing NULL as Argument.
But JVM does not call main Method as Null, Instead it Pass a Empty String Array as argument.
Question : What is the Difference between the compareTo Method and equals method in Java?
Answer : equals method() : Check whether two strings are equal or not by content and true or false.
compareTo method() : Check lexiographically returns the difference between the chars.
Pitfalls :
IF two names are same but represented in different languages then Equals method gives
false.
No comments:
Post a Comment