public class Node

{ 

   private String data;  

   private Node next;

  

   public Node()

   {

      this.setData("");     

      this.setNext(null);

   }

  

   public Node(String name)

   {

      this.setData(name);

      this.setNext(null);

   } 

   

   public Node getNext()

   {

                  return next;

   }

 

   public void setNext(Node nxNode)

   {

                   this.next = nxNode;

   }

 

   public void setData(String name)

   {

                   this.data = name;

   }

 

   public String getData()

   {

      return data;

   }  

}

 

 

 

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

 

 

public class List

{

   private Node head;

 

   //======================================

   public List()

   {      

      setHead(null);

   }

   

   public Node getHead()

   {

                   return head;

   }

 

   public void setHead(Node hd)

   {

                   this.head = hd;

   }

 

   //=======================================

   

   public boolean isEmpty()

   {

      if(head != null)

      {

                  return false;

      }

      return true;

   }

  

   public int sizeofList()

   {

                   if(isEmpty())

                   {                              

                                   return 0; // empty list

                   }             

                   Node current = head;

                   int counter =0;

                   while (current != null)

                   {

                                   current = current.getNext();

                                   counter++;

                   }

                   return counter;

   }

 

 //=======================================

 

   public int xyz()  

   {

                   if(isEmpty())

                   {  

                                   return -1; // empty list

                   }             

                   Node current = head;

                   Node maxN = head;

                   int max = 0;

                   int nb = -1;

                   boolean stop = false;

 

                   while (current != null && !stop)

                   {

                                   if(current.getNext() == null)

                                   {

                                         current.setNext(head);

                                         stop = true;

                                    }

                                    try

                                   {

                                                   nb = Integer.parseInt(current.getData());                        

                                                   if(nb > max)

                                                   {

                                                                max = nb;

                                                                maxN = current;                                                                 

                                                   }

                                   }

                                   catch(NumberFormatException e)

                                   {

                                                System.out.println("Invalid number " + current.getData() );

                                   }

                               if(stop)

                               {

                                          break;

                                }

                      current = current.getNext();

                   }

                 

              current = head;

             while (current.getNext() != maxN)

            { 

                          current = current.getNext();

            }

           current.setNext(null);

           head = maxN;

           

           return max;

   }

}