请问
发表在Java答疑区
2017-03-30
是否精华
是
否
版块置顶:
是
否
class Bike
{
string name;
int price;
public Bike(string name, int price)
{
this.name = name;
this.price = price;
}
public void print()
{
Console.WriteLine("name is " + name);
Console.WriteLine("price is " + price);
}
}
class test
{
static void Main(string[] args)
{
Bike bike = new Bike("bmw", 10000);
bike.print();
}
}
这局 public Bike(string name, int price)里面的string name, int price类似于局部变量,我记得局部变量要初始化,否则就会报错,但是这里面好像没有初始化,是不是Bike bike = new Bike("bmw", 10000);将"bmw", 10000传过去初始化了并且将值又赋给成员变量了?
首页上一页 1 下一页尾页 1 条记录 1/1页