Skip to main content
Code Review

Return to Answer

Commonmark migration
Source Link
##Naming:

Naming:

##Hiding inner classes:

Hiding inner classes:

##Consistency:

Consistency:

##Naming:

##Hiding inner classes:

##Consistency:

Naming:

Hiding inner classes:

Consistency:

replaced http://codereview.stackexchange.com/ with https://codereview.stackexchange.com/
Source Link

Additionally the inner class is static. This prevents access from the inner class to the outer one when using this. For more information have a look at this CR-Answer. this CR-Answer.

Additionally the inner class is static. This prevents access from the inner class to the outer one when using this. For more information have a look at this CR-Answer.

Additionally the inner class is static. This prevents access from the inner class to the outer one when using this. For more information have a look at this CR-Answer.

added 61 characters in body
Source Link
Vogel612
  • 25.5k
  • 7
  • 59
  • 141

##Inheriting:

You did create a List. In Java it's customary to implement Interfaces if you have classes with similar use-cases and methods.

public class list<T> {

This should/could be:

(削除) Inheriting:

You did create a List. In Java it's customary to implement Interfaces if you have classes with similar use-cases and methods.

public class list<T> {

This should/could be:

public class List<T> implements java.util.List<T> {

In fact (削除ここまで)

public class List<T> implements java.util.List<T> {
##Naming:

In fact I suggest you also change the name of your implementation to avoid confustion. Java already comes with two lists ((iinterface)java.util.List and (cclass)java.awt.List), that are just named List, you don't really need to introduce a third one ;)

By the way, if you implement an interface you are required to Override the methods that are specified by it.

In the case of List that's quite a few, including but not restricted to:

public int size();
public boolean isEmpty();
public boolean contains(T item);
public void add(T item);
public void remove(T item);

When implementing them make sure to use the @Override annotation:

@Override
public void add(T item) {
 Node<T> oldHead = this.head;
 this.head = new Node<T>(item);
 head.setNext(oldHead);
 oldHead.setPrev(head);
 size++;
}

Which brings me to my next point:

(削除) By the way, if you implement an interface you are required to Override the methods that are specified by it.

In the case of List that's quite a few, including but not restricted to:

public int size();
public boolean isEmpty();
public boolean contains(T item);
public void add(T item);
public void remove(T item);

When implementing them make sure to use the @Override annotation:

@Override
public void add(T item) {
 Node<T> oldHead = this.head;
 this.head = new Node<T>(item);
 head.setNext(oldHead);
 oldHead.setPrev(head);
 size++;
}

Which brings me to my next point: (削除ここまで)

While we're at itconstructors / initialization:

##Inheriting:

You did create a List. In Java it's customary to implement Interfaces if you have classes with similar use-cases and methods.

public class list<T> {

This should/could be:

public class List<T> implements java.util.List<T> {

In fact I suggest you also change the name of your implementation to avoid confustion. Java already comes with two lists ((i)java.util.List and (c)java.awt.List), that are just named List, you don't really need to introduce a third one ;)

By the way, if you implement an interface you are required to Override the methods that are specified by it.

In the case of List that's quite a few, including but not restricted to:

public int size();
public boolean isEmpty();
public boolean contains(T item);
public void add(T item);
public void remove(T item);

When implementing them make sure to use the @Override annotation:

@Override
public void add(T item) {
 Node<T> oldHead = this.head;
 this.head = new Node<T>(item);
 head.setNext(oldHead);
 oldHead.setPrev(head);
 size++;
}

Which brings me to my next point:

While we're at it:

(削除) Inheriting:

You did create a List. In Java it's customary to implement Interfaces if you have classes with similar use-cases and methods.

public class list<T> {

This should/could be:

public class List<T> implements java.util.List<T> {

In fact (削除ここまで)##Naming:

I suggest you change the name of your implementation to avoid confustion. Java already comes with two lists ((interface)java.util.List and (class)java.awt.List), that are just named List, you don't really need to introduce a third one ;)

(削除) By the way, if you implement an interface you are required to Override the methods that are specified by it.

In the case of List that's quite a few, including but not restricted to:

public int size();
public boolean isEmpty();
public boolean contains(T item);
public void add(T item);
public void remove(T item);

When implementing them make sure to use the @Override annotation:

@Override
public void add(T item) {
 Node<T> oldHead = this.head;
 this.head = new Node<T>(item);
 head.setNext(oldHead);
 oldHead.setPrev(head);
 size++;
}

Which brings me to my next point: (削除ここまで)

While we're at constructors / initialization:

added 319 characters in body
Source Link
Vogel612
  • 25.5k
  • 7
  • 59
  • 141
Loading
minor corrections to MyList implementation
Source Link
Vogel612
  • 25.5k
  • 7
  • 59
  • 141
Loading
Source Link
Vogel612
  • 25.5k
  • 7
  • 59
  • 141
Loading
lang-java

AltStyle によって変換されたページ (->オリジナル) /