Friday, 16 August 2013

I cant take percent of any value of numbers in jtextfield

I cant take percent of any value of numbers in jtextfield

I'm trying to take %2 of anytypes of value in jtextfield. But when i press
the button, it's giving me result "0" . Always 0. Can somone help me ?
try{
int num1=Integer.parseInt(jTextField6.getText());
int result=num1%2;
jTextField15.setText(""+result);
} catch(NumberFormatException e) {
}

No comments:

Post a Comment