会员可以在此提问,百战程序员老师有问必答
对大家有帮助的问答会被标记为“推荐”
看完课程过来浏览一下别人提的问题,会帮你学得更全面
截止目前,同学们一共提了 132482个问题
JAVA 全系列/第三阶段:数据库编程/Oracle 数据库的使用 30076楼


JAVA 全系列/第十阶段:百战旅游网项目/百战旅游网 30077楼
WEB前端全系列/第七阶段:ECMAScript6新特性模块/ES6第一部分 30078楼
JAVA 全系列/第一阶段:JAVA 快速入门/变量、数据类型、运算符 30079楼
JAVA 全系列/第三阶段:数据库编程/Oracle 数据库的使用 30080楼
JAVA 全系列/第十八阶段:亿级高并发电商项目_架构/编码(旧)/电商:基于FastDFS+Nginx+Kinkeditor实现商品新增 30081楼

style>
        .box{
            width: 234px;
            height: 300px;
            background-color: pink;
            position: relative;
            overflow: hidden;
        }
        .box1{
            width: 100%;
            height: 76px;
            background-color: orange;
            /*绝对定位  相对于已经定位的父元素定位*/
            position: absolute;
            /*据父元素上面的距离为300px*/
            top: 300px;
            /*据父元素的左侧距离为0*/
            left: 0px;
        }
        /*鼠标悬停在box上,子代box1*/
        .box:hover>.box1{
           /*据父元素上面的距离变为224*/
            top: 224px;
        }
        .box2{
            width: 303px;
            height: 375px;
            background-color: red;
            position: relative;
        }
        .box2>img{
            width: 100%;
            height: 100%;
        }
        .box3{
            width: 100%;
            height: 100%;
            background-color: salmon(0,0,0,.2);
            position: absolute;
            top: 0px;
            left: 303px;
        }
        .box2:hover>.box3{
            left: 0;
        }
    </style>
</head>
<body>
    <div class="box">
        <div class="box1"></div>
    </div>
    <div class="box2">
        <img src="img/370ad36f-425c-453a-b406-ccb2a0dffeec.jpg" alt="">
        <div class="box3"></div>
    </div>
</body>
</html>

老师,我这个代码哪里不对吗?为啥达不到老师说的效果


WEB前端全系列/第一阶段:HTML5+CSS3模块/CSS常用属性 30082楼
JAVA 全系列/第四阶段:网页编程和设计/jQuery 30083楼

老师,请问为什么会报错啊

package com.bjsxt;

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.index--;
        //如果有元素,则返回栈顶元素
        return (E) this.arr[index--];
    }


    //向栈顶添加元素
    public E push(E item) {
        //初始化数组
        this.capacity();
        //向数组中添加元素
        this.arr[++index] = item;
        //记录元素个数
        this.size++;
        return item;
    }


    //数组初始化或者以1.5倍容量对数组扩容
    private void capacity() {
        //数组初始化
        if (this.arr == null) {
            this.arr = new Object[this.stackLength];
        }
        //以1.5倍对数组扩容
        if (this.size - this.stackLength >= 0) {
            this.stackLength = this.stackLength + this.stackLength >> 1;   //>>右位移一位等于除以2
            this.arr = Arrays.copyOf(this.arr, this.stackLength);
        }
    }


    public static void main(String[] args) {
        MyStack<String> myStack=new MyStack<>();
        myStack.push("a");
        myStack.push("b");
        myStack.push("c");

        System.out.println(myStack.size);

        System.out.println(myStack.pop());
        System.out.println(myStack.pop());



    }

}


JAVA 全系列/第二阶段:JAVA 基础深化和提高/数据结构 30086楼
JAVA 全系列/第七阶段:生产环境部署与协同开发/Linux 30087楼
JAVA 全系列/第十三阶段:分布式文件存储与数据缓存/MongoDB 30088楼

课程分类

百战程序员微信公众号

百战程序员微信小程序

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