How to use set method of a different class in java? -


how can set value of parameter of class a in class b using setvara method of class a?

public class a{  string vara; public string getvara() {         return vara;     } public void setvara(string vara) {         this.vara=vara;     } }  public class b{  string name = "abc"; obja = new a(); obja.setvara(name) ; ## lines throws error  } 

the error is:

syntax error on token "name", variabledeclaratorid expected after token , syntax error on token(s), misplaced constructs 

public class a{      string vara;     public string getvara() {         return vara;     }     public void setvara(string vara) {         this.vara=vara;     } }  class b {     string name = "abc";     obja = new a();      b() {         obja.setvara(name);     } } 

Comments

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -