+ 2
Pls i dont understand why the last line of my code refuses to load
public class Life { void bark() { System.out.println("Woof-Woof"); } void neigh() { System.out.println("hufff!!"); } void singer() { System.out.println("Kapachumarimarichupako"); } } class Myclass{ public static void main(String []args) { Life dog=new Life(); Life horse=new Life(); Life zlatan=new Life(); dog.bark(); horse.neigh(); singer.zlatan(); //not ibrahimovic pls } } I don't know why the last line refuses to load
7 Respuestas
+ 2
zlatan is the object and singer is the method but on your last line you have written vice versa
+ 1
zlatan is not a method, so a call like ...zlatan() cannot work. What did you intent with this line?
+ 1
Maybe you wanted zlatan.singer() ?
+ 1
Sandra Meyer...I was just playing around with it...other lines worked but this one didn't ...So I was confused...
But I did everything the same way...So why the difference or does Java choose words?
+ 1
Thanks very much... I've seen it already...
+ 1
You're welcome 🙃
0
zlatan is your object. singer is a method of this type. Take a closer look, you did not exactly the same as in the both lines above...