代码:
/** * 获取当前结点的祖先结点 */ public List<E> getForefathers(E item){ //获取当前结点的父结点 E parent = this.getParent(item); //结束递归的边界条件 if (parent == null){ return new ArrayList<>(); } //递归调用,再次获取当前父结点的父结点 List<E> list = this.getForefathers(parent); //将递归到的所有结点元素添加到返回的 list 中 list.add(parent); return list; }
问题一:请问这里的List对象是在第一次运行代码的时候就创建的吗?
//递归调用,再次获取当前父结点的父结点 List<E> list = this.getForefathers(parent);
还是在最后一次递归到根结点时返回的new ArrayList呀?
if (parent == null){ return new ArrayList<>(); }
问题二:如果是在第一次运行就创建的List对象,那么这里每次运行都是这段代码,不会每次递归都创建一个新的List对象吗?
List<E> list = this.getForefathers(parent);
package integre.fang.com; /** * 自己手写得包装类 * * */ public class MyInteger01 { private int value; public static final int LOW=-128; public static final int HIGH=127; private static MyInteger01[] myInteger01; static { for (int i=LOW;i<=HIGH;i++){ myInteger01[i+128]=MyInteger01.getMyinteger(i);//核心得点在这里,有点迷糊 } } public MyInteger01(int a) { this.value = a; } public static MyInteger01 getMyinteger(int a){ if (LOW<=a && a<=HIGH){ return myInteger01[a+128]; } return new MyInteger01(a); } public static void main(String[] args) { int a=100; int b=100; MyInteger01 m1=new MyInteger01(300); MyInteger01 m2=new MyInteger01(300); MyInteger01 m3=new MyInteger01(100); MyInteger01 m4=new MyInteger01(100); System.out.println(m1==m2); System.out.println(m3==m4); //System.out.println(MyInteger01.getMyinteger(a)==MyInteger01.getMyinteger(b)); //System.out.println(MyInteger01.getMyinteger(a).equals(MyInteger01.getMyinteger(b))); int c=1000; int d=1000; //System.out.println(MyInteger01.getMyinteger(c)==MyInteger01.getMyinteger(d)); //System.out.println(MyInteger01.getMyinteger(c).equals(MyInteger01.getMyinteger(d))); } }
Exception in thread "main" java.lang.ExceptionInInitializerError
老师帮忙看看哪里出错了?
fastdsfdemo.rar
做fastdsf项目,一直报这个错,说是找不到方法,老师帮忙看一下
老师,这个再[-127,127]不是自动拆箱吧?只不过是Integer在这个区间内规定了是对象在这个常量池里。老师帮忙解释一下。
老师,数据库的外键具体指什么?作用是什么?一个表的外键必须是另一个表的主键吗?
老师我用的是pycharm2020,为什么我每次运行程序都要点下边这个 我记得之前都是上边那样run直接运行程序的 现在只能点下边这个 这是为什么
还有一个老师 为什么我的这个 项目上边一直有个红色的错号
老师老师,请问为什么我的会出现这样的错误,还是乱码的?
老师,按照视频老师的操作,为何,我这里的插件,是这样的?
启动服务器报了这个错误,老师你能看看这个错误吗
请问一下,这里为什么会输出0.0?添加了第30—32行代码后,才出现的,未添加前不会输出0.0
为什么provider不是web项目,consumer是web项目?
为什么fit_intercept要设置为false,是不是因为x_train之前就设置了include_bias=true,所以x_poly_train里面包括了截距项的原因?请详细告知
老师请问一下,我在本机上用jar也不行,集群上也不行,这是项目的问题,还是我环境变量没有设置好。这个项目就是从您给的资料上面下载下来的
package com.bjsxt; public class TestThread extends Thread { public TestThread() { System.out.println(this.getName()); } /** * 线程的线程体 */ @Override public void run() { System.out.println(this.getName()+"线程开始"); for (int i=0;i<20;i++){ System.out.println(this.getName()+" "+i); } System.out.println(this.getName()+"线程结束"); } public static void main(String[] args) { System.out.println("主线程开始"); TestThread t1 = new TestThread(); TestThread t2 = new TestThread(); t1.start(); t2.start(); System.out.println("主线程结束"); } }
老师为什么我的线程只会一个一个进行,
老师,我这个检查了好多遍,防火墙也给关了但是运行了好多遍就是不行
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637