Hi what is JAVA equivalent to this peace of code written in C#
class 1 :
public string Password
{
get { return password; }
set { password = value; }
}
class 2 :
try
{
UserEntity user = new UserEntity();
user.Password = textBoxPassword.Text;
user.InsertUser();
MessageBox.Show("User is registred");
}
in java I wrote this :
class 1 :
protected int password ;
public int getPassword(){
return password;
}
public void setPassword(int password){
this.password=password;
}
class2 :
LoginEntity login = new LoginEntity();
login.getPassword() = pwdTextBox.getText();// here ERROR : required variable , found value
In neither C# nor in Java can you have a method call on the left side of an assignment. So this:
is not valid in either Java or C#
Perhaps you want
Though you really should avoid using Strings for passwords as they can be easily sniffed making your password protection poor.