I'm trying to take a string of a number i.e. 123456 of any size and then convert each int in the string to an int to be added to a linked list. I.E.
read 1 convert to int then add to linked list, read 2 convert to int then add to linked list, etc. I can't figure out a way to read an individual int in the string. I can parse the whole string to an int but thats not what I want. Not sure if the .split() for strings will work here because there is no pattern and I need to accept negatives and decimal fractions. I tried messing around with a char array but didn't see any way to convert from char to int. Here is my snippet:
It's a little funky looking from me just trying the Char array but it's what I have. Any input/thoughts on where to go from here would be great. Thanks.
public void accept(String str){
int i = 0;
char[] temp = new char[i];
for(i = 0; i < str.length(); i++){
str.getChars(i, i, temp, i);
int val = Character..parseInt(temp[i]);
insertLow(val);
}
System.out.println("The string is " + toString());
}