how to convert string to int in Java
This question already has an answer here:
Ask following questions to your self first.
String cipherText = cc.encrypt(plainText,key);
mean? String
or int
? Use methods like Integer.parseInt(String value)
or Integer.valueOf(String value)
for conversion.
It seems like you need to convert a String
to int
, not a int
to String
. To do that, you can use Integer.parseInt()
:
int someInt = Integer.parseInt(someString);
You are passing String and the method parameter seems to have int and hence the error. You might want to convert your string
to int
using int keyInt = Integer.parseInt(key);
and similarly for plain text if necessary and then pass keyInt and/or plainTextInt as the parameters.
上一篇: Java:将字符串转换为Int(未知源)
下一篇: 如何在Java中将字符串转换为int