在java中我們對(duì)屬性設(shè)置值或者獲取值是通過(guò)set和個(gè)頭方法的,在C#中有點(diǎn)不同,在java中用習(xí)慣了,所以有點(diǎn)不適應(yīng)。看代碼
public class studyingClass
{
private float width=2;
public float Width
{
get { return this.width; }
set { width = value; }
}
}
java{
private float width=2;
public float Width
{
get { return this.width; }
set { width = value; }
}
}
public class Studyingclass
{
private float width=2;
public float getWidth()
{return width;}
public void setWidth(float value)
{this.width=value;}
}
明白了這個(gè)就好用了。
{
private float width=2;
public float getWidth()
{return width;}
public void setWidth(float value)
{this.width=value;}
}
明白了這個(gè)就好用了。