copyfiles.zip
把原目录下的所有文件复制到原目录中的某个文件夹就会陷入无限循环。
为什么我这个不能有这个老师的可以有
如果使用另一台电脑写服务器端程序,是不是发送不过去?
LinkedList说是查询慢是因为没有索引,但是这章中的add像特定位置加元素,就是找到它的索引,然后再加元素,这不就矛盾了吗
老师,我发现int temp和String temp两种方法都可以输出字符流喔,怎么回事呢
老师,mt.length就是返回数组长度的这个方法是指返回你有多少个元素,还是指你定义的长度为10,比如我定义数组长度是10,然后在里面放三个元素,那我返回length是10还是3
问题二,假设如果是返回10的,那是不是就表明this.index==mt.length只有在放满了的时候才会调用wait方法
问题三:我看这个打印结果感觉应该是返回你放了多少个元素,那放一个元素你的length和index不应该是一样的吗,那不是每次都会调用,为什么是偶尔等于呢
问题四:老师这里定义的index没有初始化赋值,是不是默认的为0,int类型的
老师您好,为什么Socket socket = null;要写在try外卖?我怎么判断什么写在里面,什么写在外面?
package com.bjsxt.Set_HashSet; import java.util.Objects; public class Person { private String name; private int age; public String getName() { return name; } public void setName(String name) { this.name = name; } public int getAge() { return age; } public void setAge(int age) { this.age = age; } public Person() { } public Person(String name, int age) { this.name = name; this.age = age; } @Override public boolean equals(Object o) { System.out.println("equals"); if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Person person = (Person) o; return age == person.age && Objects.equals(name, person.name); } @Override public int hashCode() { System.out.println("hashcode"); return Objects.hash(name, age); } @Override public String toString() { return "name="+this.name+","+"age="+this.age; } } package com.bjsxt.Set_HashSet; import java.util.HashSet; public class TestPerson { public static void main(String[] args) { HashSet hs=new HashSet(); Person p1=new Person("marry",20); Person p2=new Person("lili",23); Person p3=new Person("marry",20); Person p4=new Person("jack",30); hs.add(p1); hs.add(p2); hs.add(p3); hs.add(p4); System.out.println(hs); } }
为什么我在HashSet方法创建自定义对象 在输出时直接输出HashSet对象 时如果不重写toString方法输出的就是Person对象的地址值呢
我看老师并没重写toString方法啊
老师,为啥我的文件当中没有schema这个文件呢?
package com.Thread; //生产者和消费者模式 public class produceThreadTest { public static void main(String[] args) { //创建缓冲区 SyncStack ss = new SyncStack(); //启动生产者线程 produce producer = new produce(ss); new Thread(producer).start(); //启动消费者线程 new customer(ss).start(); } } //定义馒头类代表数据 class Mantou{ private int id; public int getId() { return id; } public void setId(int id) { this.id = id; } } //定义缓冲区 class SyncStack { //用数组表示放馒头的盒子 private Mantou[] mantous = new Mantou[10]; //定义索引用来操作盒子 private int index; //定义放馒头的方法 public synchronized void SetMantou(Mantou mantou) { //当馒头放满时,线程进行等待 while (this.index == this.mantous.length) { try { /** * wait()是Object类下的方法; * wait()语法:该方法需要在synchronized语句块中使用; * wait()执行后,线程会将持有的对象锁释放,并进入阻塞状态、使其他持有该对象锁的线程可以继续运行 */ this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } this.notify(); this.mantous[this.index] = mantou; this.index++; } //定义取馒头的方法 public synchronized Mantou GetMantou() { while (this.index == 0) { try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } //唤醒等待中的其中一个线程、需使用在synchronized语句块中 this.notify(); this.index--; return this.mantous[this.index]; } } //定义生产者线程类 class produce implements Runnable{ private SyncStack syncStack; public produce(SyncStack syncStack) { this.syncStack = syncStack; } public void run() { for(int i = 0;i < 10;i++){ Mantou mantou = new Mantou(); mantou.setId(i); this.syncStack.SetMantou(mantou); System.out.println("生成馒头 "+mantou.getId()); } } } //定义消费者线程类 class customer extends Thread{ private SyncStack syncStack; public customer(SyncStack syncStack) { this.syncStack = syncStack; } public void run() { for (int i = 0;i<10;i++){ Mantou mantou = this.syncStack.GetMantou(); System.out.println("取馒头 "+mantou.getId()); } } }
疑问:为什么我运行后,会先取馒头再生产馒头?
xml.zip
代码没错啊,都直接复制了教程代码,路径也没问题,是idea的问题么
我这个程序就很离谱——为什么我是八个?(好家伙 为什么非得20个字才能提问。。。。。)
1661090930378.jpg报错求解
老师我想问问 我这里报错是在哪里啊 我排查了下 没找出原因
PriorityTest Runnable { =Boolean =@override (){ (.){ System..println(Thread.().getName()+)} } (){ .=} } PriorityTest{ (String args){ Priority p1=Priority()Priority p2=Priority()Thread t1=Thread(p1name:)Thread t2=Thread(p2name:)t1.setPriority(Thread.)t2.setPriority(Thread.)t1.start()t2.start()Thread.(millis:)} }
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637