2013-02-27 82 views
-3

我爲下面的類做了一個參數構造函數,但不知道如何將它分配給類變量color。爲類提供一個參數構造函數

public class MyClass{ 
    private String colour; 
    public MyClass(String s){ 
    } 

請幫助....

+6

'顏色= S;'? – assylias 2013-02-27 21:56:51

+0

或'this.coclor = s' ??? – PermGenError 2013-02-27 21:57:52

回答

3
public class MyClass{ 
    private String color; 
    public MyClass(String color){ 
     this.color = color; 
    } 
    ... 
} 
+0

非常感謝... – Sandra 2013-02-27 22:01:03

相關問題