Tuesday, September 9, 2014

A quick review of the Java programming language keywords:
final : final class cannot be derived
          final method cannot be overridden
          final variable can be initialized once, reference cannot be changed but value can be updated.
default:
      lets you add new methods to existing interfaces
native:
      to invoke platform dependent code (generally in other languages)
strictfp:
      is used to make the floating point operations predictable across platforms
super:
     if the method overrides a superclass' method, the overriden method can be invoked by super
synchronized :
     a method marked synchronized acquires a monitor for mutual exclusion before execution.
transient:
     variables marked as transient are not part of the persistent state of the object.
volatile :
     is used for threadsafe updates to shared variables


public void removeAll(Entry<E> head, int val) throws RuntimeException()
{

 if (head == null) throw RuntimeException();

 Entry<E> prev = null;
 Entry<E> current = head;

while (current)
{
    Entry<E> next = current.next;
    if (current.val == val)
    {
           if (prev != null)
               prev.next = next;
          else
                head.next = next;
          current = next;
     }
     else
     {
               prev = current;
               current = next;
      }
}
}

No comments:

Post a Comment