public class Test3 { public static void main(String[ ] args) { Integer in1 = -128; Integer in2 = -128; System.out.println(in1 == in2);//true 因为123在缓存范围内 System.out.println(in1.equals(in2));//true Integer in3 = 1234; Integer in4 = 1234; System.out.println(in3 == in4);//false 因为1234不在缓存范围内 System.out.println(in3.equals(in4));//true } }
老师,为什么说某个值在缓存区间内判断的时候返回的就是true呢
求助老师,我用测试类的主方法打印数字,另启一个线程打印字母,但是字母为打印。源码如下,求指点
test类
package cn.zhjb.printer; public class Test { public static void main(String[] args) { new Thread(new thread()).start(); for (int i =1;i <=52;i++) { new Printer().print(i); } } } class thread implements Runnable{ @Override public void run() { for (char c = 'A';c<='Z';c++) { new Printer().print(c); } } }
Printer类
package cn.zhjb.printer; public class Printer { private int index = 1;//用于统计是第几次打印 /**写打印数字方法*/ public synchronized void print(int number) { if (index%3==0) { try { super.wait(); } catch (InterruptedException e) { e.printStackTrace(); } }else { System.out.println(number); super.notifyAll(); } index++; } /**打印字母的方法*/ public synchronized void print(char ch) { if (index%3!=0) { try { super.wait(); } catch (InterruptedException e) { e.printStackTrace(); } }else { System.out.println(ch); super.notifyAll(); } index++; } }
关于邮箱的正则表达式:
在@后边,是通过\\. 来表达 . 的作用吗?
邮箱的@后,一定会有一个点或者多个点,比如
@qq.com
@gmail.com
@pku.edu.cn
关于点,为什么在正则表达式中没有规定?
如果有输出. 是如连字符-直接写吗?还是需要转义字符?
(o1,o2) -> o1.compareTo(o2)
为什么就是升序,而不是降序?内部是怎么判断的,是根据字符对应数值的大小进行比较吗?
如果是多个字母
aabb abbb
这个的升序比较结果又是什么嗯?
老师,请问这个Closeable为啥能代表是所有IO流的类型,他是个什么
Vector<String> stack = new Stack<>(); //这样写是不是可以理解为多态的特性 List<String> vector = new Vector<>(); //这样的又是面向接口编程
所以面向接口编程和多态有什么关系吗
老师这个程序目前无法启动能帮忙看看吗?,直接就关闭程序
代码:
package com.bjsxt.server; import java.io.BufferedWriter; import java.io.IOException; import java.io.InputStream; import java.io.OutputStreamWriter; import java.net.ServerSocket; import java.net.Socket; import com.bjsxt.servlet.Servlet; import com.bjsxt.util.IOCloseUtil; public class Server {//服务器,用于启动和停止服务 private ServerSocket server; private boolean isShutDown=false;//默认没有出错 public static void main(String[] args) { Server server=new Server();//创建服务器对象 server.start(); } public void start(){ this.start(8888); } public void start(int port){ try { server=new ServerSocket(port); this.receive(); //调用接收请求信息的方法 } catch (IOException e) { isShutDown=true; } } private void receive() { try { while(!isShutDown){ //(1)监听 System.out.println("wserefserew"); Socket client=server.accept(); //创建线程类的对象 Dispatcher dis=new Dispatcher(client); //创建线程的代理类,并启动线程 new Thread(dis).start(); } } catch (IOException e) { this.stop();//关闭服务器 } } public void stop(){ isShutDown=true; try { server.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } //IOCloseUtil.closeAll(server); } }
截图:
老师,第二阶段的视频播放声音有点小,可不可以调大点
老师,我用的是苹果本,这个文件字节输出流的写法是不是和老师写的喝个不太一样啊
老师,
当链表长度大于8时就会转换为红黑树,这个的前提条件是不是数组长度大于等于64才能转换?
如果链表长度大于8,数组长度小于64,是不是链表不会转换成红黑树,而是数组进行扩容?
如果上面的两个问题是对的话,那激发数组扩容的条件是不是有两个,一个就是当数组被沾满75%,另一个是链表长度大于8(数组长度小于64)
老师你好,我这个通配符哪儿是不对嘛结果不一样,第二个是测试第一个的,但是不成功,返回null,下面返回50,不知道为什么,麻烦 老师解答一下
Set<Student> set = new TreeSet<>(new StudentComparator);
这一步TreeSet传入StudentComparator怎么理解呢
这块为什么会报错,,,,,,,,,,,,,,,
为什么没有让步?
我的代码跟老师你的一样,为什么运行结果不一样呢
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637