[Solved] Java convert string to int
[ad_1] Assuming you have a string of digits (e.g. “123”), you can use toCharArray() instead: for (char c : pesel.toCharArray()) { temp += 3 * (c – ‘0’); } This avoids Integer.parseInt() altogether. If you want to ensure that each character is a digit, you can use Character.isDigit(). Your error is because str.split(“”) contains a … Read more