我按照老师的额代码去写,但是,出不来,怎么回事?哪里出现错误了?
我放到代码块中了啊,为啥还是乱码啊啊!!!!!
老师,既然是以1970年00:00:00进行加减计算时间,输入1000,为啥不是00:00:01而是以上运算的时间
方法:有返回值调用时只需创建一对象通过对象名加方法名直接打印 MethodCeneric methodCeneric = new MethodCeneric(); methodCeneric.setName("mamamiya"); 而没有返回值的为什么需要把对象名加方法名,赋给一个变量在用sout打印那个变量呢 MethodCeneric methodCeneric1 = new MethodCeneric(); String a =methodCeneric1.getName("mama"); System.out.println(a);
我想问一下这个异常怎么改啊
package com.bjsxt; /** * 生产者消费者模式 */ public class ProduceThread { public static void main(String[] args) { SyncStack ss = new SyncStack(); new Producer(ss).start(); new Consumer(ss).start(); } } /** * 创建缓冲区 */ class ManTou{ /**定义馒头类*/ private int id; public ManTou(int id) { this.id = id; } public int getId() { return id; } } class SyncStack{ /**定义缓冲区类*/ private ManTou[] mt = new ManTou[10]; // 定义存放馒头的盒子 private int index; // 定义操作盒子的索引 /**放馒头*/ public synchronized void push(ManTou manTou){ // 判断盒子满否 while (this.index == this.mt.length){ /** * 语法:wait(),该方法必须要在synchronized块中调用。 * wait执行后,线程会将持有的对象锁释放,并进入阻塞状态, * 其他需要该对象锁的线程就可以继续运行了。 */ try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } // 唤醒取馒头的线程 /** * 语法:该方法必须要在synchronized块中调用。 * 该方法会唤醒处于等待状态队列中的一个线程。 */ this.notify(); this.mt[index] = manTou; index++; } /**取馒头*/ public synchronized ManTou pop(){ while (index == 0){ try { this.wait(); } catch (InterruptedException e) { e.printStackTrace(); } } this.notify(); index--; return this.mt[index]; } } /** * 创建生产者消费者线程 */ class Producer extends Thread{ /**定义生产者线程类*/ private SyncStack ss; public Producer(SyncStack ss){ this.ss = ss; } @Override public void run() { for (int i=1; i<11; i++){ System.out.println("生产馒头:"+i); this.ss.push(new ManTou(i)); } } } class Consumer extends Thread{ /**定义消费者线程类*/ private SyncStack ss; public Consumer(SyncStack ss){ this.ss = ss; } @Override public void run() { for (int i=1; i<11; i++){ ManTou manTou = this.ss.pop(); System.out.println("消费馒头:"+i); } } }
附上代码,照着讲义敲的(只改了几个名字)
老师,我想问一下,这个已经过时了不建议使用,那可以使用哪一个来代替它呢?
list.removeIf(Predicate.isEqual());
我感觉用这种方法更方便...按老师给定一个参数ele,这个ele是起到一个遍历作用吗?
老师,toString方法中输出的线程组名称 那个线程组是什么?
代码运行没有报错,也跟其他优秀案例比较过,但是就是服务端开启、客户端开启后,多个客户端之间不能互通聊天。麻烦老师看下,代码已经附上了
代码.rar
我的自动生成这个有问题马?还是两种都可以
字符串的compareTo方法比较字符串小于0返回-1,和大于0返回1代表什么意思呢?
compareto方法之前在哪学的?返回去找没找到
import java.net.InetAddress; import java.net.UnknownHostException; public class InetTest3 { public static void main(String[] args) throws UnknownHostException { //根据IP地址获取计算机信息:需使用getByName("IP")方法创建InetAddress对象 InetAddress inetAddress = InetAddress.getByName("183.232.231.174"); //返回IP地址 System.out.println(inetAddress.getHostAddress()); //返回计算机名 System.out.println(inetAddress.getHostName()); } }
为什么没有返回计算机名呢?
请问本节课里老师打开的 jdk1.8 中文 有道翻译版 这个从哪里可以获取?
什么是监听与监听器?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637