取消考虑点后的数字

Desconsider number after dot

我只想保留点前的数字,我不想保留点后的数字。例如:

double x = 5.6
int y = 5 // the part before dot 

为此,我有以下代码:

SeekBar tipSeekBar;
EditText tipAmountET;
double tipAmount;
tipAmount = (tipSeekBar.getProgress()) * .01;               
NumberFormat format = NumberFormat.getInstance(Locale.US);
Number number;
number = format.parse(String.valueOf(tipAmount));
double d = number.doubleValue();
String resultado = String.valueOf(d * 100);
tipAmountET.setText(resultado);     

我试图在 resultado 上使用拆分,但它给了我异常 ArrayOutOfBoundsException。像这样,在最后一行之前:

String[] split = resultado.split(".");
tipAmountET.setText(split[0]);

y 转换后同样为 5:

double x = 5.6
int y = (int) x;

不就是施展它给你想要的吗?

double x = 5.6;
int y = (int)x;
System.out.println(y);