import java.util.*;
public class MainAssignment3
{
public static void main(String[]args)
{
int Max =0;
int Value =0;

LinkedList<Integer>Input=new LinkedList<Integer>();
LinkedList<Integer>Temp=new LinkedList<Integer>();
LinkedList<Integer>OutPut=new LinkedList<Integer>();

Input.addLast(90);
Input.addLast(21);
Input.addLast(33);
Input.addLast(80);
Input.addLast(67);

System.out.println("The Input Stack is : " + Input);

while(!Input.isEmpty())
{
Max = (Integer)Input.removeLast();
Value = (Integer)Input.removeLast();

System.out.println("MAx: " +Max);
System.out.println("Value: " +Value);

if (Value < Max)
{
Temp.addLast(Max);
Max=Value;

} else {
Temp.addLast(Value);
}


Input = Temp;
OutPut.addLast(Max);
Temp.clear();
System.out.println(OutPut);

}
}
}

Input Stack should is [90, 21, 33, 80, 67]
OutPut Stack Should is [21, 33, 67, 80 ,90]
But i Only Get [67]
any solution help ?

Related to posting thread, have you heard about CODE TAGS?
Also can you please write a few sentences telling what you need and what you are trying to do.

Related to your problem, have you heard about DEBUGGING?
What do you think the following line does?? Input = Temp;

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.