I have an array of String, containing doubles. An example could be a String containing [5, ., 2]. I want to be the double 2,5.
I know this is very confusing, but the way I got those numbers like that, is from an input like: "y=2.5x+4.3" (the variable called ligning).
while(erTal(ligning.substring((ligning.indexOf("x")-i),(ligning.indexOf("x")-i+1))) == true){
xVærdi.add(ligning.substring((ligning.indexOf("x")-i),(ligning.indexOf("x")-i+1)));
System.out.println("There's a number to the left of x. Der er tilføjet " + i + " tal i alt");
i++;
}
Method to check if String is number:
public static boolean erTal(String str) {
if(str.equals("+") || str.equals("-") || str.equals("*") || str.equals("/") || str.equals("=")){
return false;
} else {
return true;
}
}