I get the output they ask for when passing in the examples URLs, but it won't verify
package com.codegym.task.task15.task1527;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
/*
Request parser
*/
public class Solution {
public static void main(String[] args) throws IOException{
boolean debug = true;
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
//String url = "http://codegym.cc/alpha/index.html?lvl=15&view&name=Amigo";
//String url = "http://codegym.cc/alpha/index.html?obj=3.14&name=Amigo";
String url = reader.readLine();
String [] stringSplits = url.split("[?&]");
ArrayList<String> listOfParams = new ArrayList<>();
Double doubleToBeDisplayed = 0.0;
String stringToBeDisplayed = "-";
for(int i = 0; i < stringSplits.length; i++) {
if (i > 0) {
String[] split2 = stringSplits[i].split("=");
if (split2[0].contains("obj")) {
try {
Double d = Double.parseDouble(split2[1]);
listOfParams.add(split2[0]);
doubleToBeDisplayed = d;
}catch (NumberFormatException e){
stringToBeDisplayed = (split2[1]);
}
} else listOfParams.add(split2[0]);
}
}
for(String element : listOfParams){
System.out.print(element + " ");
}
System.out.println();
if(!doubleToBeDisplayed.equals(0.0)){
alert(doubleToBeDisplayed);
}else if (!stringToBeDisplayed.equals("-")) {
alert(stringToBeDisplayed);
}
}
public static void alert(double value) {
System.out.println("double: " + value);
}
public static void alert(String value) {
System.out.println("String: " + value);
}
}