0
How to fix this error please help guys
I make an method animal but when I am using it in if statement. It's not fetching the animal method https://code.sololearn.com/c46upj2DhDgO/?ref=app
1 Answer
+ 4
Did you mean passing an argument to the method? Try this:
class ani{
static void animal(String name){
if(name =="dog"){
System.out.println("bark");
}
else if(name =="cat"){
System.out.println("meow");
}else{
System.out.println("choose between cat or dog");
}
}
public static void main(String[]args){
animal("cat");
}
}