"8. For instance" not working


#1

I have no idea why I can't get this to work, can anybody please help?

My code is:

class Person
  def initialize(name, profession, age)
    @name = name
    @profession = profession
    @age = age
  end
end

Error message is:

"Oops, try again. It looks like your @age instance variable isn't set equal to the age parameter passed to your initialize method."

Thanks

Tim


#2

class Test
{
String name;
int age;
Test(String name,int age)//variables have local scope
{
this.name=name;//we do following steps to make global scope for name,age(instance variables)
this,age=age;
}

public static void main(String args[])
{

 Test i =new Test("adf",12);//object creation and constructor calling

}
}


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.