会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132906个问题
JAVA 全系列/(隐藏)第二十三阶段:数字货币交易所项目/项目的简介 26223楼

this.size++报错哪里出问题了
/*
* 基于双向链表实现元素存储的容器
* */
public class MyDoublyLinkedList<E> implements MyList<E> {

    /*
    * 定义双向链表的节点对象
    * */
    class Node<E>{
         E item;
         Node<E> prev;      //记录前一个节点对象
         Node<E> next;      // 记录下一个节点对象
         Node(Node<E> prev,E item,Node<E> next){
             this.prev = prev;
             this.item = item;
             this.next = next;
         }
    }
    private  Node head;   //记录头节点
    private  Node tail;   //记录尾节点
    private  Node size;   //记录原元素个数

    /*
    * 向双向链表中添加元素的方法
    * */
    @Override
    public void add(E element) {
        this.linkLast(element);
    }

    /*
    * 将节点对象添加到双向链表尾部
    * */
    private void linkLast(E element){
        //获取尾节点
        Node t = this.tail;
        //创建节点对象
        Node<E> node = new Node<>(t,element,null);
        //将新节点定义为尾节点
        this.tail = node;
        if(t == null){
            this.head = node;
        }else{
            t.next = node;
        }
        this.size++
    }

    /*
    * 根据指定位置获取元素
    * */
    @Override
    public E get(int indxe) {
        return null;
    }

    /*
    * 返回元素个数
    * */
    @Override
    public int size() {
        return 0;
    }

    /*
    * 根据指定位置删除元素*/
    @Override
    public E remove(int index) {
        return null;
    }

    public static void main(String[] args) {

    }
}

image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/数据结构 26224楼


小米官网实战.rar

你好 老师 那个slide不是应该定位到wrap 吗不知道为什么给定到黑色导航去了

WEB前端全系列/第一阶段:HTML5+CSS3模块/商城官网项目 26225楼

为什么size数值为0?
package 栈结构;

import java.util.Arrays;
import java.util.EmptyStackException;

public class MyStack<E>{
    private Object[] arr;
    private int stackLength =4;
    private int size;
    private int index =-1;


    public boolean empty(){
        return this.size==0;
    }


    public E pop(){
        if (this.index == -1){
                throw new EmptyStackException();
    }
        this.size--;
        return  (E)this.arr[index--];
    }


    public  E push(E item){
        this.capacity();
        this.arr[++index]=item;
        return item;
    }

    private void capacity(){
        if ( this.arr==null ){
            this.arr=new Object[this.stackLength];
        }
        if (this.size-(this.stackLength-1)>=0 ){
            this.stackLength=this.stackLength+(this.stackLength>>1);
            this.arr= Arrays.copyOf(this.arr,this.stackLength);
        }
    }

    public static void main( String[] args ) {
        MyStack<String> ms = new MyStack<>();
        ms.push("a");
        ms.push("b");
        ms.push("c");
        System.out.println(ms.size);
        System.out.println(ms.pop() );
        System.out.println(ms.pop() );
        System.out.println(ms.pop() );
    }
}

image.png

JAVA 全系列/第二阶段:JAVA 基础深化和提高/数据结构 26226楼
WEB前端全系列/第二阶段:JavaScript编程模块/面向对象编程 26228楼
JAVA 全系列/第二阶段:JAVA 基础深化和提高/多线程技术(旧) 26229楼
JAVA 全系列/第五阶段:JavaWeb开发/Servlet技术详解 26230楼
Python 全系列/第二阶段:Python 深入与提高/文件处理 26231楼
Python 全系列/第二阶段:Python 深入与提高/GUI编程(隐藏) 26232楼
JAVA 全系列/第八阶段:Linux入门到实战/Linux(旧) 26233楼
Python 全系列/第七阶段:网页编程基础/CSS 样式 26234楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园
网站维护:百战汇智(北京)科技有限公司
京公网安备 11011402011233号    京ICP备18060230号-3    营业执照    经营许可证:京B2-20212637