Skip to content

Commit

Permalink
Merge pull request #6579 from chartypes/main
Browse files Browse the repository at this point in the history
#11 - Java
  • Loading branch information
Roswell468 authored Jun 15, 2024
2 parents d7854b7 + f430bcc commit 76c15a6
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions Retos/Reto #11 - URL PARAMS [Fácil]/java/chartypes.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@

class Main {
public static void main(String[] args) {
String url = "https://retosdeprogramacion.com?year=2023&challenge=0";
getParams(url);

}

public static void getParams(String url) {
String paramsUrl = url.split("\\?")[1];
String[] keyValueParams = paramsUrl.split("&");
int paramsSize = keyValueParams.length;
String[] params = new String[paramsSize];
System.out.print("[");

for (int i = 0; i < paramsSize; i++) {
String param = keyValueParams[i];
String value = param.split("=")[1];

params[i] = value;

if (i == paramsSize-1)
System.out.print(", ");

System.out.print(value);

}
System.out.print("]");

}

}

0 comments on commit 76c15a6

Please sign in to comment.