+ 1
help me decode please ( java ), I kept on changing the code until I am really tired, sorry I am a beginner at Java.
public class Animals{ String name; int age; int legs; static class Cats { static void legs=4; void propert() { System.out.print("Miow, my name is " this.name); System.out.println("my age is " + this.age + " , I have " + legs + " legs." ); } } } class MyClass{ public static void main(String []args){ Animals.Cats jex=new Animals.Cats(); jex.name="Jex"; jex.age=14; jex.propert(); } }
2 Answers
+ 1
In 6th line delete void keywords
Correct is static legs=4;
In propert method definition correct print statement is
System.out.print("Miow, my name is"+this.name);
You skip +before this . name it generates compilation error because of that and
Please don't paste code here write code in code playground and insert your code here so that others can edit
+ 1
kamesh shekhar prasad thank you very much and sorry, I won't my code here.