小编aym*_*man的帖子

which is better to use request.getParameter() or @RequestParm?

Which way is considered as better Software Engineering practice in spring:

1) using the spring annotation @RequestParam

@RequestMapping(value = "/doSomeThing", method = RequestMethod.GET)
@ResponseBody
public boolean doSomeThing(@RequestParam("name") String name) {
    boolean success = false;
    // do the logic
    return success;
}
Run Code Online (Sandbox Code Playgroud)

2) using the request method getParameter

@RequestMapping(value = "/doSomeThing2", method = RequestMethod.GET)
@ResponseBody
public boolean doSomeThing2(HttpServletRequest request) {
    boolean success = false;
    String name = request.getParameter("name");
    // do the logic
    return success;
}
Run Code Online (Sandbox Code Playgroud)

java spring

3
推荐指数
1
解决办法
389
查看次数

这种递归算法的复杂性是什么?

以下算法是否具有O(nlogn)的复杂度?

令我困惑的是这个算法分为两次,而不是一次作为常规的O(nlogn)算法,并且每次它都进行O(n)工作.

def equivalent(a, b):

    if isEqual(a, b):
        return True

    half = int(len(a) / 2)
    if 2*half != len(a):
        return False

    if (equivalent(a[:half], b[:half]) and equivalent(a[half:], b[half:])):
        return True

    if (equivalent(a[:half], b[half:]) and equivalent(a[half:], b[:half])):
        return True

    return False
Run Code Online (Sandbox Code Playgroud)

python algorithm time-complexity

1
推荐指数
1
解决办法
138
查看次数

泛型方法用于消除重载方法

我读了一些关于泛型方法的内容,我发现它用于消除重载方法.

public static void main(String[] args) {
    Integer arr[] = { 12, 55, 66, 54 };

    printArray(arr);
}

public static <T> void printArray(T arr[]) {
    for (T a : arr) {
        System.out.print(a.toString() + " ");
    }
    System.out.println();
}
Run Code Online (Sandbox Code Playgroud)

在了解有关泛型方法的任何内容之前,我曾经做过如下的事情:

public static void main(String[] args) {
    Integer arr[] = { 12, 55, 66, 54 };

    printArray(arr);
}

public static void printArray(Object arr[]) {
    for (Object a : arr) {
        System.out.print(a.toString() + " ");
    }
    System.out.println();
}
Run Code Online (Sandbox Code Playgroud)

这两种方式有什么不同......?

java

0
推荐指数
1
解决办法
79
查看次数

标签 统计

java ×2

algorithm ×1

python ×1

spring ×1

time-complexity ×1