I found that this code work well and when I print it I have "Infinity". I don't understand how can we put value Infinity in primitive type, I thought that it will be error.
String s = "Infinity";
double d = Double.valueOf(s);
System.out.println(d);