当前位置: 代码迷 >> J2SE >> 请问一下高手, 怎样implement method stack by methods from queues,
  详细解决方案

请问一下高手, 怎样implement method stack by methods from queues,

热度:449   发布时间:2016-04-24 14:57:48.0
请教一下高手, 怎样implement method stack by methods from queues, 急
实在不好意思,   跑来请教一下高手,   怎样implement   method   stack   by   methods   from   queues,   can 't   using   java.util,   ?   我卡在pop()上了,   我是这么想的,
      /*dequeue   all   elements   of   queue1   and   enqueue   them   into   queue2
        *   only   left   the   last   element   and   set   as   a   temp   variable
        *   then   dequeue   all   the   elements   from   queue2   and   enqueue   them   back   to   queue1
        *   @return   the   temp   varible   as   the   result   of   the   pop   method   */

然后是这么写的,   但是问题出在the   last   element   上,   我把它设成TEMP了,   但是不知道应该怎样做成LOCAL   VARIABLE,   请帮我看一下,   拜托

          //temp   =   null;
            for(int   i   =   queue1.size()-1;   i   >   1;   i--){
                  if(i==1){
              <E>   temp   =   queue1;   }
              queue2.enqueue(queue1.dequeue());        
              queue1.enqueue(queue2.dequeue());
      }//end   for
            return   <E> temp;

------解决方案--------------------
学习
  相关解决方案