Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.HashMap;
import java.util.Map;

public class Main {
    public static void main(String[] args) {
        String query = "name==p==?header=hello?aname=?????lname=lastname";
        String[] params = query.split("\\?");
        Map<String, String> map = new HashMap<String, String>();
        for (String param : params) {
            String name = param.split("=")[0];
            String value = param.substring(name.length(), param.length());
            map.put(name, value);
            System.out.println(name);
            if (name.equals("")) {
                value += "?";
            }
            System.out.println(value.replaceAll(" ", ""));
        }
    }
}