老师,这里@ResponseBody的作用是啥来着?有些忘记了
这个<context-param>中的值是不是全局共享的?是不是放在全局容器中的?
视频中有两处错误,没有考虑到100分的情况和当输错一次成绩的时候再次输入成绩的时候不会显示,我这边的程序已经进行过更改,请老师过目
score=(()) degree=score>score<: score1=(()) num=score1//num<: num =(degree[-num]) : num=score//num<: num =(degree[-num])
折线图里面为什么1号数量都是0 呢
老师你好,为什我这里加上新建和初始化函数,就报错了。根据错误提示网上找了找,做了排除还是没解决。去除这两个函数又可以正常运行了。
去除后
a=a+1那里,得到的结果怎么是4.1400000001
为什么不是4.14
老师,视频中的这一块,我按照老师的代码写,输出是有空格的,但是在前面加‘!’时,输出就正确,
视频中老师的意思是:如果得到的字符串不等于空,就去掉首尾空格吗?
为什么我这里要加一个非才能实现呢?
老师,同步代码块中 wait()方法及 notify() 方法是用 this 对象调用的,那这个对象到底是哪个类下的对象?是 缓冲区 BufferZone 类下实例化的对象嘛?
// 馒头类 class SteamBread { private int id; public SteamBread(int id) { this.id = id; } public int getId() { return this.id; } } // 缓冲区类 class BufferZone { // 存放馒头的盒子 private SteamBread[] sb = new SteamBread[10]; // 定义操作盒子的索引 private int index; // 生产者方法馒头 public synchronized void put(SteamBread steamBread) { while (this.index >= this.sb.length) { try { this.wait(); // this 引用当前类的实例,所以对应的对象为 BufferZone 类下实例化的对象 bz } catch (InterruptedException e) { e.printStackTrace(); } } this.notify(); this.sb[this.index] = steamBread; this.index++; } // 取馒头 public synchronized SteamBread take() { while (this.index == 0) { try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } this.notify(); this.index--; return this.sb[this.index]; } } // 生产者线程类 class ProducerThread extends Thread { private BufferZone bz; public ProducerThread(BufferZone bz) { this.bz = bz; } @Override public void run() { for (int i = 0; i < 10; ++i) { System.out.println("生产馒头:" + i); SteamBread sb = new SteamBread(i); this.bz.put(sb); } } } // 消费者线程类 class ConsumerThread extends Thread { private BufferZone bz; public ConsumerThread(BufferZone bz) { this.bz = bz; } @Override public void run() { for (int i = 0; i < 10; ++i) { SteamBread sb = this.bz.take(); System.out.println("消费馒头:" + i); } } } // 测试生产者消费者模式 public class ProducerConsumerModel { public static void main(String[] args) { BufferZone bz = new BufferZone(); new ProducerThread(bz).start(); new ConsumerThread(bz).start(); } }
老师,在自己写线程代码时,不知道怎么确定共享资源,如果自己确定这个例子的共享资源,不知到怎么下手。有没有什么好的办法确定共享资源?谢谢
老师我这个代码为矩形为什么有个先用了turtle.penup() 和turtle.pendown()这两个矩形合不上了为什么呀谢谢老师帮我讲解一下
问题:switch()中最后default后面可以不写break; 也好像对,还是都写规范写吗?
老师,是如何保证发送线程和接受线程的锁都是同一个锁呢,视频中的是”abc“,那如果一个是”abc“,一个是”abcd“还能保证这两个线程是同一个锁吗
老师,这种情况是什么原因引起的呢?还有怎么解决?
报错,请老师指点迷津。
hashset.rar
老师,使用 new 关键字新建 Student 类的对象 student,和获取 Class 对象,然后调用 newInstance() 方法新建对象 students 有啥区别?应该都算是调用 Student 类的无参构造器新建对象吧。
public class ReflectionPerformanceTest01 { public static void main(String[] args) throws Exception { // Reflection // obtain Class object Student student = new Student(); Class classObject01 = student.getClass(); Class classObject02 = Student.class; Class classObject03 = Class.forName("com.bjsxt.demo.Student"); // test students is equal student?是不是都是算是调用无参构造器创建对象? // 此外,使用这两种方式创建的对象调用方法,很明显一个使用了反射,一个没有使用反射,所以效率会有明显的差距。 Student students =(Student) classObject03.newInstance(); long reflectionStart = System.currentTimeMillis(); Method method = classObject03.getMethod("setName", String.class); final int cycle = 10000000; for ( int i = 0; i < cycle; ++i) { // method.invoke(student,"John"); // new 关键字新建对象 student method.invoke(students,"John"); // Class 对象调用 newInstance() 方法获取对象 } long reflectionEnd = System.currentTimeMillis(); System.out.println(reflectionEnd - reflectionStart); System.out.println("----------------"); // non reflection long start = System.currentTimeMillis(); for (int i = 0; i < cycle; ++i) { student.setName("Marry"); } long end = System.currentTimeMillis(); System.out.println(end - start); } }
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637