package com.bjsxt.homework.Thread; public class JoinThread { public static void main(String[] args) { System.out.println("main线程开始"); Thread t1 = new Thread(new A()); t1.start(); //new B().start(); for(int i =0;i<10;i++){ System.out.println(Thread.currentThread().getName()+"正在运行"+i); //i=3时,main被挂起,直到A执行完。 if (i == 3) { try { t1.join(); } catch (InterruptedException e) { e.printStackTrace(); } } } System.out.println("main线程结束"); } } class A implements Runnable{ Thread t = new B(); @Override public void run() { t.run(); for(int i =0;i<10;i++){ System.out.println(Thread.currentThread().getName()+"正在运行"+i); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } //i=5时,A被挂起,直到B执行完。 if(i==5){ try { t.join(); } catch (InterruptedException e) { e.printStackTrace(); } } }} } class B extends Thread{ @Override public void run() { for(int i =0;i<10;i++){ System.out.println(Thread.currentThread().getName()+"正在运行!!!"+i); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }
老师,getDeclaredConstructor()获取指定的构造方法,那括号里面只能写一个数据类型吗?
请问为什么
public synchronized void get() { if(!isFlag)//没有商品{ { try { // super.wait(); this.wait(); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } }//消费者线程被唤醒之后从下面开始执行 System.out.println("消费者线程取走了"+this.getBrand()+this.getName()); //取走商品后通知生产者线程 super.notify(); // this.notify(); isFlag = false; }
上述代码里面要用super.wait()和super.notify()?
不应该是当前线程等待和通知吗?测试了一下,this.wait()和this.notify()效果一样
查不出报错的原因,知道在34行。。。。。。。。
之前的问题看了后面的视频了解了,还是不太明白。为什么要把容量设置成255呢?请老师指点
https://www.sxt.cn/Java_jQuery_in_action/History_Direction.html
老师这个链接的文档是还没更新呢吗 感觉有好多东西和视频不太符合 后面的也不全
老师请问一下,视频中网络爬虫那个,在存储到本地这一步为啥要使用
BufferedWriter bw=new BufferedWriter(new OutputStreamWriter(new FileOutputStream("index.html"),"UTF-8"));
还要用转换流,直接写成
BufferedWriter bw=new BufferedWriter(new FileWriter("index1.html"));
不行吗?
老师,红黑树的路径是什么划分的,跟节点分为子节点,而子节点中又有叶子节点,它的路径划分是从子节点开始到根节点吗
package com.bjsxt.array; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.DataOutputStream; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Date; public class Test { public static void main(String[] args) { byte [] buf=write();//调用写对象的方法 //调用读对象的方法 read(buf); } public static byte[] write(){ //创建字节数组流对象 ByteArrayOutputStream baos=null; ObjectOutputStream oos=null; try { baos=new ByteArrayOutputStream();//创建字节数组流对象,目的地是字节数组,底层创建一个长度数为32的字节数组 oos=new ObjectOutputStream(baos); oos.writeInt(98); oos.writeDouble(98.5); oos.writeChar('a'); oos.writeBoolean(false); oos.writeObject(new Date(1000)); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ //关闭流 if (oos!=null) { try { oos.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } return baos.toByteArray(); } public static void read(byte [] buf){ ByteArrayInputStream bais=null; ObjectInputStream ois=null; //创建对象 try { bais=new ByteArrayInputStream(buf); //数据源是byte类型的数组 ois=new ObjectInputStream(bais); //读数据 System.out.println(ois.readInt()); System.out.println(ois.readDouble()); System.out.println(ois.readChar()); System.out.println(ois.readBoolean()); System.out.println(ois.readObject()); } catch (ClassNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ //关闭流 if(ois!=null){ try { ois.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } }
这里主函数去调用写出方法时是这样调用的
byte [] buf=write();//调用写对象的方法
有什么说法吗 第一次见这种写法
已经导入jaxen包了,为啥还是会出现找不包的异常,用的是IDEA
package com.zheng.TestXML; import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Node; import org.dom4j.io.SAXReader; import java.io.File; public class TextXpath { public static void main(String[] args) throws DocumentException { //1) 创建 SAXReader 对象 SAXReader reader = new SAXReader(); //2) 调用 read 方法 Document doc = reader.read(new File("books.xml")); //3) Node node = doc.selectSingleNode("//name"); System.out.println("节点的名称:"+node.getName()+"节点的值"+node.getText()); } } "E:\学习软件大集合\IDEA\IntelliJ IDEA 2019.3.2\jbr\bin\java.exe" "-javaagent:E:\学习软件大集合\IDEA\IntelliJ IDEA 2019.3.2\lib\idea_rt.jar=49244:E:\学习软件大集合\IDEA\IntelliJ IDEA 2019.3.2\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\zheng\Desktop\mycode\Process\out\production\XML;C:\Users\zheng\Desktop\mycode\Process\lib\jdom.jar;C:\Users\zheng\Desktop\mycode\Process\lib\dom4j-1.6.1.jar com.zheng.TestXML.TextXpath WARNING: An illegal reflective access operation has occurred WARNING: Illegal reflective access by org.dom4j.io.SAXContentHandler (file:/C:/Users/zheng/Desktop/mycode/Process/lib/dom4j-1.6.1.jar) to method com.sun.org.apache.xerces.internal.parsers.AbstractSAXParser$LocatorProxy.getEncoding() WARNING: Please consider reporting this to the maintainers of org.dom4j.io.SAXContentHandler WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations WARNING: All illegal access operations will be denied in a future release Exception in thread "main" java.lang.NoClassDefFoundError: org/jaxen/JaxenException at org.dom4j.DocumentFactory.createXPath(DocumentFactory.java:230) at org.dom4j.tree.AbstractNode.createXPath(AbstractNode.java:207) at org.dom4j.tree.AbstractNode.selectSingleNode(AbstractNode.java:183) at com.zheng.TestXML.TextXpath.main(TextXpath.java:22) Caused by: java.lang.ClassNotFoundException: org.jaxen.JaxenException at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581) at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) ... 4 more
package com.itbaizhan; class Iphone{ private String name; public Iphone(String name){ this.name=name; } public void show(){ System.out.println("我是 "+name+"可以在屏幕上显示"); } } class touyingPhone{ public Iphone iphone; //它只是个扩展,必须有前一个东西才能扩展。这里的Iphone,就是继承于Iphone的意思。iPhone是参数 public touyingPhone(Iphone iphone){ this.iphone=iphone; } //功能更强的 方法 public void show(){ iphone.show(); System.out.println("还能投影,在墙上"); } } public class TestDecoration { public static void main(String[] args) { Iphone i=new Iphone("苹果199代"); i.show(); System.out.println("======加上装饰器后======"); touyingPhone typ=new touyingPhone(Iphone); typ.show(); } }
这个报错实在是找不到该怎么解决,视频看了两遍了都没头绪
1.座机号分为区号和后面七位或者八位,后面的第一位不能是0;
找到原因了……应该是t.start()~~~~~~~~~~
老师,
socket.getOutputStream()
在没有通信之前,不是空吗?
为什么可以放到PrintWriter?
都是对同一个对象操作,为什么在转化回去之后结果不一样了呢?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637