There are some difficulties in learning Java .
Idea
Create a pet that will simply say what he wants in the most primitive way.
Code:
Main class
public class Progs { public static void main(String[] args){ Pet MyPet = new Pet(); MyPet.says(); } }
Side effects
public class Pet { String[] all_says = {"Я хочу кушать","Я хочу пить","Все отлично"}; public String says(String namePet, int needPet){ String nd; if(needPet == 1){ nd = all_says[1]; } else{ if(needPet == 2){ nd = all_says[2]; } else{ nd = all_says[3]; } } System.out.println(namePet + ":" + nd); } } public class Fish{ String name = "Karlson"; int need = 1; Pet MyPet = new Pet(); MyPet.says(name, need); }
Mistake:
The Eclipse compiler produces the following error:
Exception in thread "java.lang.Error: Unresolved compilation of the problem: The method says (String, int) in the type of pet." At Progs.main (Progs.java.)
And yes, I know English and it says here that types are not applicable for arguments. But I do not understand what is wrong?