小编Nev*_*423的帖子

Java Generics E extends Comparable <E>留下警告

我正在尝试创建一个Generic类,E extends Comparable E但我在Eclipse中收到一条警告说:

LinkedList.Node是原始类型.应该参数化对泛型类型LinkedList E .Node E的引用

这是代码:

public class LinkedList<E extends Comparable<E>>



{
    // reference to the head node.
    private Node head;
    private int listCount;

    // LinkedList constructor
 public void add(E data)
    // post: appends the specified element to the end of this list.
    {
        Node temp = new Node(data);
        Node current = head;
        // starting at the head node, crawl to the end of the list
        while(current.getNext() != null)
        {
            current = current.getNext();
        }
        // …
Run Code Online (Sandbox Code Playgroud)

java generics

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

Big-O符号检查理解

我想检查一下我对Big-O表示法的理解.如果我有代码:

 for(int bound = 1; bound <= n; bound *= 2){
      for( int i = 0; i < bound; i++) {
            for(int j = 0; j < n; j += 2){
                   .....Code
            }
            for(int j = 1; j < n; j *= 2){
                   ......Code
            }
      }
 }
Run Code Online (Sandbox Code Playgroud)

这个N 3的Big-O表示法?

java big-o

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

标签 统计

java ×2

big-o ×1

generics ×1