I have created the isDouble class which is from the previous FromHell exercise "Different methods for different types" which checks if a number has "." in it meaning it is a double.
This class's method is used in line 75.
What have I done wrong?
package com.codegym.task.task15.task1527;
import org.apache.commons.lang3.StringUtils;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
import java.net.URL;
import java.net.URLDecoder;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.codegym.task.task15.task1527.IsDouble.isNumeric;
import static java.util.regex.Pattern.LITERAL;
/*
Request parser
*/
public class Solution {
public static void main(String[] args) {
//write your code here
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String input = null;
try {
input = reader.readLine();
} catch (IOException e) {
e.printStackTrace();
}
URL url = null;
String _Query = null;
try {
url = new URL(input);
// get the Query
_Query = url.getQuery();
// display the URL
//System.out.println("URL = " + url);
// display the Query
//System.out.println(" Query= " + _Query);
}
// if any error occurs
catch (Exception e) {
// display the error
System.out.println(e);
}
String[] arrOfStr = _Query.split("&");
List<String> newArrOfStr = new ArrayList<>();
//now i need to eliminate elements after =
for (String it : arrOfStr) {
if (it.contains("="))
{
int index3 = it.indexOf("=");
it = it.substring(0, index3);
}
System.out.print(it + " "); //this prints the elements of the array
}
System.out.println();
//so far it's correct
for (String it1 : arrOfStr) {
int index4 = it1.indexOf("=");
newArrOfStr.add(it1.substring(index4+1));
}
//now I have added to it2 the string after = . I must check if that string is a double
for (String it2 : newArrOfStr) {
if (isNumeric(it2)) {
if (it2.contains(".")) {
alert(Double.parseDouble(it2));
}
}
}
}
public static void alert(double value) {
System.out.println("double: " + value);
}
public static void alert(String value) {
System.out.println("String: " + value);
}
}