How is this possible? (Junit exception testing of linked list implementationHow do you assert that a certain exception is thrown in JUnit 4 tests?JUnit test for System.out.println()Conditionally ignoring tests in JUnit 4How to run JUnit test cases from the command lineHow to detect a loop in a linked list?Maven does not find JUnit tests to runJunit implements Iterablereversing a linked list in groups of a given sizeCan someone show me a simple working implementation of PagerSlidingTabStrip?Java Manual Implementation of Doubly Link List

Write to EXCEL from SQL DB using VBA script

Unexpected email from Yorkshire Bank

Is it appropriate to refer to God as "It"?

Why do freehub and cassette have only one position that matches?

Can fracking help reduce CO2?

Parsing with CCGs - lambda part

Why is Thanos so tough at the beginning of "Avengers: Endgame"?

Entropy as a function of temperature: is temperature well defined?

What happens if I start too many background jobs?

When and why did journal article titles become descriptive, rather than creatively allusive?

Public Salesforce Site and Security Review

Is every dg-coalgebra the colimit of its finite dimensional dg-subcoalgebras?

How could a planet have most of its water in the atmosphere?

What does air vanishing on contact sound like?

How to efficiently calculate prefix sum of frequencies of characters in a string?

Who died in the Game of Thrones episode, "The Long Night"?

Pigeonhole Principle Problem

How to get SEEK accessing converted ID via view

Why is Arya visibly scared in the library in S8E3?

I lost my Irish passport. Can I travel to Thailand and back from the UK using my US passport?

What was the state of the German rail system in 1944?

Unidentified items in bicycle tube repair kit

How do I tell my manager that his code review comment is wrong?

How can I close a gap between my fence and my neighbor's that's on his side of the property line?



How is this possible? (Junit exception testing of linked list implementation


How do you assert that a certain exception is thrown in JUnit 4 tests?JUnit test for System.out.println()Conditionally ignoring tests in JUnit 4How to run JUnit test cases from the command lineHow to detect a loop in a linked list?Maven does not find JUnit tests to runJunit implements Iterablereversing a linked list in groups of a given sizeCan someone show me a simple working implementation of PagerSlidingTabStrip?Java Manual Implementation of Doubly Link List






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I am writing a LinkedList implementation which includes a previous function that returns the position prior to the one passed as an input argument. It should check whether the inputted position is the first one and throw an exception in that case:



@Override
public Position<T> previous (Position<T> p) throws PositionException
if (this.first(p))
throw new PositionException();

return this.convert(p).prev;



However, the following test is failing because it isn't throwing the expected exception from trying to use the previous function on the first position in the array:



@Test (expected=PositionException.class)
public void gettingPreviousAtFront()
Position<String> one = list.insertFront("One");
Position<String> two = list.insertFront("Two");
assertTrue(list.first(two));
Position<String> beforeTwo = list.previous(two);




There was 1 failure: 1)
gettingPreviousAtFront(hw6.test.LinkedListTest)
java.lang.AssertionError: Expected exception:
exceptions.PositionException at
org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:32)




It is even passing the assertion on line 301 of the test that "two" is first. So how is it possible that the exception is not being thrown by the previous function?



Here is the full linkedlist code:



package hw6;

import exceptions.EmptyException;
import exceptions.PositionException;

import java.util.Iterator;
import java.util.NoSuchElementException;


public class LinkedList<T> implements List<T>

private static final class Node<T> implements Position<T>
// The usual doubly-linked list stuff.
Node<T> next; // reference to the Node after this
Node<T> prev; // reference to the Node before this
T data;

// List that created this node, to validate positions.
List<T> owner;

@Override
public T get()
return this.data;


@Override
public void put(T t)
this.data = t;



/** This iterator can be used to create either a forward
iterator, or a backwards one.
*/
private final class ListIterator implements Iterator<T>
Node<T> current;
boolean forward;

ListIterator(boolean f)
this.forward = f;
if (this.forward)
this.current = LinkedList.this.sentinelHead.next;
else
this.current = LinkedList.this.sentinelTail.prev;



@Override
public T next() throws NoSuchElementException
if (!this.hasNext())
throw new NoSuchElementException();

T t = this.current.get();
if (this.forward)
this.current = this.current.next;
else
this.current = this.current.prev;

return t;


@Override
public boolean hasNext()
if (this.forward)
return this.current != LinkedList.this.sentinelTail;

else
return this.current != LinkedList.this.sentinelHead;




/* ** LinkedList instance variables are declared here! ** */

private Node<T> sentinelHead;
private Node<T> sentinelTail;
private int length; // how many nodes in the list

/**
* Create an empty list.
*/
public LinkedList()
this.sentinelHead = new Node<>();
this.sentinelTail = new Node<>();
this.sentinelHead.owner = this;
this.sentinelTail.owner = this;
this.sentinelTail.prev = this.sentinelHead;
this.sentinelHead.next = this.sentinelTail;
this.length = 0;


// Convert a position back into a node. Guards against null positions,
// positions from other data structures, and positions that belong to
// other LinkedList objects. That about covers it?
private Node<T> convert(Position<T> p) throws PositionException ClassCastException e)
throw new PositionException();



@Override
public boolean empty()
return this.length == 0;


@Override
public int length()
return this.length;


@Override
public boolean first(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
return this.sentinelHead.next == n;


@Override
public boolean last(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
return this.sentinelTail.prev == n;


@Override
public Position<T> front() throws EmptyException
if (this.length == 0)
throw new EmptyException();

return this.sentinelHead.next;


@Override
public Position<T> back() throws EmptyException
if (this.empty())
throw new EmptyException();

return this.sentinelTail.prev;


@Override
public Position<T> next(Position<T> p) throws PositionException
if (this.last(p))
throw new PositionException();

return this.convert(p).next;


@Override
public Position<T> previous(Position<T> p) throws PositionException
if (this.first(p))
throw new PositionException();

return this.convert(p).prev;


@Override
public Position<T> insertFront(T t)
return this.insertAfter(this.sentinelHead, t);


@Override
public Position<T> insertBack(T t)
return this.insertBefore(this.sentinelTail, t);


@Override
public void removeFront() throws EmptyException
this.remove(this.front());


@Override
public void removeBack() throws EmptyException
this.remove(this.back());


@Override
public void remove(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
n.owner = null;
n.prev.next = n.next;
n.next.prev = n.prev;
this.length--;


@Override
public Position<T> insertBefore(Position<T> p, T t)
throws PositionException
Node<T> current = this.convert(p);
Node<T> n = new Node<T>();
n.owner = this;
n.data = t;

n.prev = current.prev;
current.prev.next = n;
n.next = current;
current.prev = n;
this.length++;
return n;


@Override
public Position<T> insertAfter(Position<T> p, T t)
throws PositionException
Node<T> current = this.convert(p);
Node<T> n = new Node<T>();
n.owner = this;
n.data = t;

n.next = current.next;
current.next.prev = n;
n.prev = current;
current.next = n;
this.length++;
return n;


@Override
public Iterator<T> forward()
return new ListIterator(true);


@Override
public Iterator<T> backward()
return new ListIterator(false);


@Override
public Iterator<T> iterator()
return this.forward();


@Override
public String toString()
StringBuilder s = new StringBuilder();
s.append("[");
for (Node<T> n = this.sentinelHead.next; n != this.sentinelTail; n = n.next)
s.append(n.data);
if (n.next != this.sentinelTail)
s.append(", ");


s.append("]");
return s.toString();











share|improve this question



















  • 2





    It would be better if You could paste the full code instead of images. Can You paste methods: first and instertFront?

    – zolv
    Mar 22 at 20:15







  • 2





    Don't post images of code or errors, instead post them in your question as formatted text. Please edit your question to provide a Minimal, Complete, and Verifiable example demonstrating the issue. For more information about Stack Overflow and asking questions, take the tour, read How to Ask, and visit the help center.

    – Slaw
    Mar 22 at 20:23


















0















I am writing a LinkedList implementation which includes a previous function that returns the position prior to the one passed as an input argument. It should check whether the inputted position is the first one and throw an exception in that case:



@Override
public Position<T> previous (Position<T> p) throws PositionException
if (this.first(p))
throw new PositionException();

return this.convert(p).prev;



However, the following test is failing because it isn't throwing the expected exception from trying to use the previous function on the first position in the array:



@Test (expected=PositionException.class)
public void gettingPreviousAtFront()
Position<String> one = list.insertFront("One");
Position<String> two = list.insertFront("Two");
assertTrue(list.first(two));
Position<String> beforeTwo = list.previous(two);




There was 1 failure: 1)
gettingPreviousAtFront(hw6.test.LinkedListTest)
java.lang.AssertionError: Expected exception:
exceptions.PositionException at
org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:32)




It is even passing the assertion on line 301 of the test that "two" is first. So how is it possible that the exception is not being thrown by the previous function?



Here is the full linkedlist code:



package hw6;

import exceptions.EmptyException;
import exceptions.PositionException;

import java.util.Iterator;
import java.util.NoSuchElementException;


public class LinkedList<T> implements List<T>

private static final class Node<T> implements Position<T>
// The usual doubly-linked list stuff.
Node<T> next; // reference to the Node after this
Node<T> prev; // reference to the Node before this
T data;

// List that created this node, to validate positions.
List<T> owner;

@Override
public T get()
return this.data;


@Override
public void put(T t)
this.data = t;



/** This iterator can be used to create either a forward
iterator, or a backwards one.
*/
private final class ListIterator implements Iterator<T>
Node<T> current;
boolean forward;

ListIterator(boolean f)
this.forward = f;
if (this.forward)
this.current = LinkedList.this.sentinelHead.next;
else
this.current = LinkedList.this.sentinelTail.prev;



@Override
public T next() throws NoSuchElementException
if (!this.hasNext())
throw new NoSuchElementException();

T t = this.current.get();
if (this.forward)
this.current = this.current.next;
else
this.current = this.current.prev;

return t;


@Override
public boolean hasNext()
if (this.forward)
return this.current != LinkedList.this.sentinelTail;

else
return this.current != LinkedList.this.sentinelHead;




/* ** LinkedList instance variables are declared here! ** */

private Node<T> sentinelHead;
private Node<T> sentinelTail;
private int length; // how many nodes in the list

/**
* Create an empty list.
*/
public LinkedList()
this.sentinelHead = new Node<>();
this.sentinelTail = new Node<>();
this.sentinelHead.owner = this;
this.sentinelTail.owner = this;
this.sentinelTail.prev = this.sentinelHead;
this.sentinelHead.next = this.sentinelTail;
this.length = 0;


// Convert a position back into a node. Guards against null positions,
// positions from other data structures, and positions that belong to
// other LinkedList objects. That about covers it?
private Node<T> convert(Position<T> p) throws PositionException ClassCastException e)
throw new PositionException();



@Override
public boolean empty()
return this.length == 0;


@Override
public int length()
return this.length;


@Override
public boolean first(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
return this.sentinelHead.next == n;


@Override
public boolean last(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
return this.sentinelTail.prev == n;


@Override
public Position<T> front() throws EmptyException
if (this.length == 0)
throw new EmptyException();

return this.sentinelHead.next;


@Override
public Position<T> back() throws EmptyException
if (this.empty())
throw new EmptyException();

return this.sentinelTail.prev;


@Override
public Position<T> next(Position<T> p) throws PositionException
if (this.last(p))
throw new PositionException();

return this.convert(p).next;


@Override
public Position<T> previous(Position<T> p) throws PositionException
if (this.first(p))
throw new PositionException();

return this.convert(p).prev;


@Override
public Position<T> insertFront(T t)
return this.insertAfter(this.sentinelHead, t);


@Override
public Position<T> insertBack(T t)
return this.insertBefore(this.sentinelTail, t);


@Override
public void removeFront() throws EmptyException
this.remove(this.front());


@Override
public void removeBack() throws EmptyException
this.remove(this.back());


@Override
public void remove(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
n.owner = null;
n.prev.next = n.next;
n.next.prev = n.prev;
this.length--;


@Override
public Position<T> insertBefore(Position<T> p, T t)
throws PositionException
Node<T> current = this.convert(p);
Node<T> n = new Node<T>();
n.owner = this;
n.data = t;

n.prev = current.prev;
current.prev.next = n;
n.next = current;
current.prev = n;
this.length++;
return n;


@Override
public Position<T> insertAfter(Position<T> p, T t)
throws PositionException
Node<T> current = this.convert(p);
Node<T> n = new Node<T>();
n.owner = this;
n.data = t;

n.next = current.next;
current.next.prev = n;
n.prev = current;
current.next = n;
this.length++;
return n;


@Override
public Iterator<T> forward()
return new ListIterator(true);


@Override
public Iterator<T> backward()
return new ListIterator(false);


@Override
public Iterator<T> iterator()
return this.forward();


@Override
public String toString()
StringBuilder s = new StringBuilder();
s.append("[");
for (Node<T> n = this.sentinelHead.next; n != this.sentinelTail; n = n.next)
s.append(n.data);
if (n.next != this.sentinelTail)
s.append(", ");


s.append("]");
return s.toString();











share|improve this question



















  • 2





    It would be better if You could paste the full code instead of images. Can You paste methods: first and instertFront?

    – zolv
    Mar 22 at 20:15







  • 2





    Don't post images of code or errors, instead post them in your question as formatted text. Please edit your question to provide a Minimal, Complete, and Verifiable example demonstrating the issue. For more information about Stack Overflow and asking questions, take the tour, read How to Ask, and visit the help center.

    – Slaw
    Mar 22 at 20:23














0












0








0








I am writing a LinkedList implementation which includes a previous function that returns the position prior to the one passed as an input argument. It should check whether the inputted position is the first one and throw an exception in that case:



@Override
public Position<T> previous (Position<T> p) throws PositionException
if (this.first(p))
throw new PositionException();

return this.convert(p).prev;



However, the following test is failing because it isn't throwing the expected exception from trying to use the previous function on the first position in the array:



@Test (expected=PositionException.class)
public void gettingPreviousAtFront()
Position<String> one = list.insertFront("One");
Position<String> two = list.insertFront("Two");
assertTrue(list.first(two));
Position<String> beforeTwo = list.previous(two);




There was 1 failure: 1)
gettingPreviousAtFront(hw6.test.LinkedListTest)
java.lang.AssertionError: Expected exception:
exceptions.PositionException at
org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:32)




It is even passing the assertion on line 301 of the test that "two" is first. So how is it possible that the exception is not being thrown by the previous function?



Here is the full linkedlist code:



package hw6;

import exceptions.EmptyException;
import exceptions.PositionException;

import java.util.Iterator;
import java.util.NoSuchElementException;


public class LinkedList<T> implements List<T>

private static final class Node<T> implements Position<T>
// The usual doubly-linked list stuff.
Node<T> next; // reference to the Node after this
Node<T> prev; // reference to the Node before this
T data;

// List that created this node, to validate positions.
List<T> owner;

@Override
public T get()
return this.data;


@Override
public void put(T t)
this.data = t;



/** This iterator can be used to create either a forward
iterator, or a backwards one.
*/
private final class ListIterator implements Iterator<T>
Node<T> current;
boolean forward;

ListIterator(boolean f)
this.forward = f;
if (this.forward)
this.current = LinkedList.this.sentinelHead.next;
else
this.current = LinkedList.this.sentinelTail.prev;



@Override
public T next() throws NoSuchElementException
if (!this.hasNext())
throw new NoSuchElementException();

T t = this.current.get();
if (this.forward)
this.current = this.current.next;
else
this.current = this.current.prev;

return t;


@Override
public boolean hasNext()
if (this.forward)
return this.current != LinkedList.this.sentinelTail;

else
return this.current != LinkedList.this.sentinelHead;




/* ** LinkedList instance variables are declared here! ** */

private Node<T> sentinelHead;
private Node<T> sentinelTail;
private int length; // how many nodes in the list

/**
* Create an empty list.
*/
public LinkedList()
this.sentinelHead = new Node<>();
this.sentinelTail = new Node<>();
this.sentinelHead.owner = this;
this.sentinelTail.owner = this;
this.sentinelTail.prev = this.sentinelHead;
this.sentinelHead.next = this.sentinelTail;
this.length = 0;


// Convert a position back into a node. Guards against null positions,
// positions from other data structures, and positions that belong to
// other LinkedList objects. That about covers it?
private Node<T> convert(Position<T> p) throws PositionException ClassCastException e)
throw new PositionException();



@Override
public boolean empty()
return this.length == 0;


@Override
public int length()
return this.length;


@Override
public boolean first(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
return this.sentinelHead.next == n;


@Override
public boolean last(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
return this.sentinelTail.prev == n;


@Override
public Position<T> front() throws EmptyException
if (this.length == 0)
throw new EmptyException();

return this.sentinelHead.next;


@Override
public Position<T> back() throws EmptyException
if (this.empty())
throw new EmptyException();

return this.sentinelTail.prev;


@Override
public Position<T> next(Position<T> p) throws PositionException
if (this.last(p))
throw new PositionException();

return this.convert(p).next;


@Override
public Position<T> previous(Position<T> p) throws PositionException
if (this.first(p))
throw new PositionException();

return this.convert(p).prev;


@Override
public Position<T> insertFront(T t)
return this.insertAfter(this.sentinelHead, t);


@Override
public Position<T> insertBack(T t)
return this.insertBefore(this.sentinelTail, t);


@Override
public void removeFront() throws EmptyException
this.remove(this.front());


@Override
public void removeBack() throws EmptyException
this.remove(this.back());


@Override
public void remove(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
n.owner = null;
n.prev.next = n.next;
n.next.prev = n.prev;
this.length--;


@Override
public Position<T> insertBefore(Position<T> p, T t)
throws PositionException
Node<T> current = this.convert(p);
Node<T> n = new Node<T>();
n.owner = this;
n.data = t;

n.prev = current.prev;
current.prev.next = n;
n.next = current;
current.prev = n;
this.length++;
return n;


@Override
public Position<T> insertAfter(Position<T> p, T t)
throws PositionException
Node<T> current = this.convert(p);
Node<T> n = new Node<T>();
n.owner = this;
n.data = t;

n.next = current.next;
current.next.prev = n;
n.prev = current;
current.next = n;
this.length++;
return n;


@Override
public Iterator<T> forward()
return new ListIterator(true);


@Override
public Iterator<T> backward()
return new ListIterator(false);


@Override
public Iterator<T> iterator()
return this.forward();


@Override
public String toString()
StringBuilder s = new StringBuilder();
s.append("[");
for (Node<T> n = this.sentinelHead.next; n != this.sentinelTail; n = n.next)
s.append(n.data);
if (n.next != this.sentinelTail)
s.append(", ");


s.append("]");
return s.toString();











share|improve this question
















I am writing a LinkedList implementation which includes a previous function that returns the position prior to the one passed as an input argument. It should check whether the inputted position is the first one and throw an exception in that case:



@Override
public Position<T> previous (Position<T> p) throws PositionException
if (this.first(p))
throw new PositionException();

return this.convert(p).prev;



However, the following test is failing because it isn't throwing the expected exception from trying to use the previous function on the first position in the array:



@Test (expected=PositionException.class)
public void gettingPreviousAtFront()
Position<String> one = list.insertFront("One");
Position<String> two = list.insertFront("Two");
assertTrue(list.first(two));
Position<String> beforeTwo = list.previous(two);




There was 1 failure: 1)
gettingPreviousAtFront(hw6.test.LinkedListTest)
java.lang.AssertionError: Expected exception:
exceptions.PositionException at
org.junit.internal.runners.statements.ExpectException.evaluate(ExpectException.java:32)




It is even passing the assertion on line 301 of the test that "two" is first. So how is it possible that the exception is not being thrown by the previous function?



Here is the full linkedlist code:



package hw6;

import exceptions.EmptyException;
import exceptions.PositionException;

import java.util.Iterator;
import java.util.NoSuchElementException;


public class LinkedList<T> implements List<T>

private static final class Node<T> implements Position<T>
// The usual doubly-linked list stuff.
Node<T> next; // reference to the Node after this
Node<T> prev; // reference to the Node before this
T data;

// List that created this node, to validate positions.
List<T> owner;

@Override
public T get()
return this.data;


@Override
public void put(T t)
this.data = t;



/** This iterator can be used to create either a forward
iterator, or a backwards one.
*/
private final class ListIterator implements Iterator<T>
Node<T> current;
boolean forward;

ListIterator(boolean f)
this.forward = f;
if (this.forward)
this.current = LinkedList.this.sentinelHead.next;
else
this.current = LinkedList.this.sentinelTail.prev;



@Override
public T next() throws NoSuchElementException
if (!this.hasNext())
throw new NoSuchElementException();

T t = this.current.get();
if (this.forward)
this.current = this.current.next;
else
this.current = this.current.prev;

return t;


@Override
public boolean hasNext()
if (this.forward)
return this.current != LinkedList.this.sentinelTail;

else
return this.current != LinkedList.this.sentinelHead;




/* ** LinkedList instance variables are declared here! ** */

private Node<T> sentinelHead;
private Node<T> sentinelTail;
private int length; // how many nodes in the list

/**
* Create an empty list.
*/
public LinkedList()
this.sentinelHead = new Node<>();
this.sentinelTail = new Node<>();
this.sentinelHead.owner = this;
this.sentinelTail.owner = this;
this.sentinelTail.prev = this.sentinelHead;
this.sentinelHead.next = this.sentinelTail;
this.length = 0;


// Convert a position back into a node. Guards against null positions,
// positions from other data structures, and positions that belong to
// other LinkedList objects. That about covers it?
private Node<T> convert(Position<T> p) throws PositionException ClassCastException e)
throw new PositionException();



@Override
public boolean empty()
return this.length == 0;


@Override
public int length()
return this.length;


@Override
public boolean first(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
return this.sentinelHead.next == n;


@Override
public boolean last(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
return this.sentinelTail.prev == n;


@Override
public Position<T> front() throws EmptyException
if (this.length == 0)
throw new EmptyException();

return this.sentinelHead.next;


@Override
public Position<T> back() throws EmptyException
if (this.empty())
throw new EmptyException();

return this.sentinelTail.prev;


@Override
public Position<T> next(Position<T> p) throws PositionException
if (this.last(p))
throw new PositionException();

return this.convert(p).next;


@Override
public Position<T> previous(Position<T> p) throws PositionException
if (this.first(p))
throw new PositionException();

return this.convert(p).prev;


@Override
public Position<T> insertFront(T t)
return this.insertAfter(this.sentinelHead, t);


@Override
public Position<T> insertBack(T t)
return this.insertBefore(this.sentinelTail, t);


@Override
public void removeFront() throws EmptyException
this.remove(this.front());


@Override
public void removeBack() throws EmptyException
this.remove(this.back());


@Override
public void remove(Position<T> p) throws PositionException
Node<T> n = this.convert(p);
n.owner = null;
n.prev.next = n.next;
n.next.prev = n.prev;
this.length--;


@Override
public Position<T> insertBefore(Position<T> p, T t)
throws PositionException
Node<T> current = this.convert(p);
Node<T> n = new Node<T>();
n.owner = this;
n.data = t;

n.prev = current.prev;
current.prev.next = n;
n.next = current;
current.prev = n;
this.length++;
return n;


@Override
public Position<T> insertAfter(Position<T> p, T t)
throws PositionException
Node<T> current = this.convert(p);
Node<T> n = new Node<T>();
n.owner = this;
n.data = t;

n.next = current.next;
current.next.prev = n;
n.prev = current;
current.next = n;
this.length++;
return n;


@Override
public Iterator<T> forward()
return new ListIterator(true);


@Override
public Iterator<T> backward()
return new ListIterator(false);


@Override
public Iterator<T> iterator()
return this.forward();


@Override
public String toString()
StringBuilder s = new StringBuilder();
s.append("[");
for (Node<T> n = this.sentinelHead.next; n != this.sentinelTail; n = n.next)
s.append(n.data);
if (n.next != this.sentinelTail)
s.append(", ");


s.append("]");
return s.toString();








java junit linked-list






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 22 at 22:54









Alexis

1237




1237










asked Mar 22 at 20:08









jayjoajayjoa

62




62







  • 2





    It would be better if You could paste the full code instead of images. Can You paste methods: first and instertFront?

    – zolv
    Mar 22 at 20:15







  • 2





    Don't post images of code or errors, instead post them in your question as formatted text. Please edit your question to provide a Minimal, Complete, and Verifiable example demonstrating the issue. For more information about Stack Overflow and asking questions, take the tour, read How to Ask, and visit the help center.

    – Slaw
    Mar 22 at 20:23













  • 2





    It would be better if You could paste the full code instead of images. Can You paste methods: first and instertFront?

    – zolv
    Mar 22 at 20:15







  • 2





    Don't post images of code or errors, instead post them in your question as formatted text. Please edit your question to provide a Minimal, Complete, and Verifiable example demonstrating the issue. For more information about Stack Overflow and asking questions, take the tour, read How to Ask, and visit the help center.

    – Slaw
    Mar 22 at 20:23








2




2





It would be better if You could paste the full code instead of images. Can You paste methods: first and instertFront?

– zolv
Mar 22 at 20:15






It would be better if You could paste the full code instead of images. Can You paste methods: first and instertFront?

– zolv
Mar 22 at 20:15





2




2





Don't post images of code or errors, instead post them in your question as formatted text. Please edit your question to provide a Minimal, Complete, and Verifiable example demonstrating the issue. For more information about Stack Overflow and asking questions, take the tour, read How to Ask, and visit the help center.

– Slaw
Mar 22 at 20:23






Don't post images of code or errors, instead post them in your question as formatted text. Please edit your question to provide a Minimal, Complete, and Verifiable example demonstrating the issue. For more information about Stack Overflow and asking questions, take the tour, read How to Ask, and visit the help center.

– Slaw
Mar 22 at 20:23













0






active

oldest

votes












Your Answer






StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");

StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307119%2fhow-is-this-possible-junit-exception-testing-of-linked-list-implementation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307119%2fhow-is-this-possible-junit-exception-testing-of-linked-list-implementation%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

용인 삼성생명 블루밍스 목차 통계 역대 감독 선수단 응원단 경기장 같이 보기 외부 링크 둘러보기 메뉴samsungblueminx.comeh선수 명단용인 삼성생명 블루밍스용인 삼성생명 블루밍스ehsamsungblueminx.comeheheheh

155 수학 과학 기타 둘러보기 메뉴eh추가해eh문서를 완성해