Could someone please explain how hashcode works? I am new in android. All I want to do is to get the hashcode of my edittext that the user has inputted.
This is my code:
public class MainActivity extends Activity {
EditText txtCode, txtID;
Button enter;
@Override
protected void onCreate(Bundle savedInstanceState)
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
txtID = (EditText) findViewById(R.id.txtid);
txtCode = (EditText) findViewById(R.id.txtcode);
enter = (Button) findViewById(R.id.button1);
enter.setOnClickListener(new OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
String a = txtID.getText().toString();
int b = a.hashCode();
txtCode.setText(b);
}
});
}
hashCode()is not Android-specific.Object: docs.oracle.com/javase/7/docs/api/java/lang/Object.html -- the .equals()/.hashCode() contract is explained in full.