0
Can we use two different methods in a single class? For exmaple, 1) sayHello();. 2) sayHome(); if yes how to calll them?
3 ответов
+ 2
yes you can create as many method as you want
calling is depend on is your method is static or not. If your method is static you can call your method without creating object of that class.
class_name.method;
if they are not
create object like
class_name obj = new class_name();
obj.method;
for more comment below
0
if you dont have an object, u can just run the method using the name of the method followed by parentheses within its own class. If you have the method defined in a separate class, then you have to use the way shown above.
0
Yes that is one of the cool features of JAVA.But sorry I don't know how to call them as I am a 9th standard student who has just started exploring JAVA world