public E remove(int index) { // 对index 进行校验 this.checkIndex(index); // 根据指定位置获取节点对象 Node<E> node = this.getNode(index); // 获取节点对象中的元素 E item = node.item; // 将该对象中单向链表中移除 // 判断当前节点是否为头节点 if(this.head == node){ this.head = node.next; }else{ Node<E> temp = this.head; for(int i =0;i<index-1;i++){ temp = temp.next; } temp.next = node.next; } node.next = null; // 记录元素个数 this.size--; //返回元素 return item; }
老师为什么我删除元素 不返回那个元素本身
老师 ArrayList不是要重写接口中的方法嘛 重写接口中的方法之后ArrraList为什么还会拥有接口中的方法啊
老师,这个案例
的意思是不是方法套方法
为什么这里不能有set
private Account account;老师,这里我不太懂为什么可以直接用Account类型的啊?还有,那个讲super(name)的时候说把name存到super里面是什么意思啊?
老师,我这边到最后删除元素是返回来的值是空的,检查了一边没看出来什么原因
这节课是为了演示转换流才用字节流吧,一般什么情况需要用字节流读文本文件?
复制出来的图片文件是空的可能是什么问题呢?前面几个实验复制都成功了
下面文件路径我有小小遮下
package com.bjsxt; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.FileInputStream; import java.io.FileOutputStream; public class FileStreamBuffer3Demo { public static void main(String[] args) { FileInputStream fis = null; FileOutputStream fos = null; BufferedInputStream bis = null; BufferedOutputStream bos = null; try { fis = new FileInputStream("/Users/.../Documents/...jpg"); bis = new BufferedInputStream(fis); fos = new FileOutputStream("/Users/.../Documents/...jpg"); bos = new BufferedOutputStream(fos); int temp = 0; while((temp = bis.read()) != -1){ bos.write(temp); } bos.flush(); }catch (Exception e ){ e.printStackTrace(); }finally { try { }catch (Exception e){ e.printStackTrace(); } } } }
public class TestThread2 implements Runnable{ public TestThread2(){ System.out.println(Thread.currentThread().getName()); } @Override public void run() { System.out.println(Thread.currentThread().getName()+"线程开始"); for (int i = 0;i<20;i++){ System.out.println(Thread.currentThread().getName()+" "+i); } System.out.println(Thread.currentThread().getName()+"线程结束"); } public static void main(String[] args) { System.out.println("主线程开始"); TestThread2 testThread2 = new TestThread2(); Thread t1 = new Thread(testThread2); t1.start(); Thread t2 = new Thread(new TestThread2()); t2.start(); System.out.println("主线程结束"); } }
为什么我这个线程是按顺序来的?
2022版本的平行运行在哪儿呀
public void start() { Menu menu = new Menu(); TelNoteRegex regex = new TelNoteRegex(); Operate operate = new Operate(); File file = new File("/Users/JAVA/a.txt"); ObjectInputStream ois = null; Object o = null; try { file.createNewFile(); ois = new ObjectInputStream(new FileInputStream(file)); if ((o = ois.readObject())==null){ return; }else { operate.ObjectInputStreamDemo(); } } catch (Exception e) { e.printStackTrace(); } while (true) { menu.mainMenu(); int item = regex.menuItemValidate(1, 6); switch (item) { case 1: operate.addLogic(); break; case 2: operate.searchLogic(); break; case 3: operate.modifyLogic(); break; case 4: operate.deleteLogic(); break; case 5: operate.orderLogic(); break; case 6: operate.ObjectOutputStreamDemo(); System.exit(0); } } }
我在这里做了判断了,为什么还会报EOF?
public void ObjectOutputStreamDemo(){ ObjectOutputStream oos = null; try { oos = new ObjectOutputStream(new FileOutputStream("/Users/JAVA/a.txt",true)); for (Person temp:list){ oos.writeObject(temp); } oos.flush(); }catch (Exception e){ e.printStackTrace(); }finally { try { if (oos!=null){ oos.close(); } }catch (Exception e){ e.printStackTrace(); } } } public void ObjectInputStreamDemo(){ ObjectInputStream ois = null; try { ois = new ObjectInputStream(new FileInputStream("/Users/JAVA/a.txt")); Person a = null; while(true){ if ((a = (Person) ois.readObject())==null){ break; } Person person =(Person) ois.readObject(); this.list.add(person); } }catch (Exception e){ e.printStackTrace(); }finally { try { if(ois!=null){ ois.close(); } }catch (Exception e){ e.printStackTrace(); } } }
StreamCorruptedException这个报错我该怎么修改呢,有时候if语句中还会报类型强制转换的错误是为什么呢
老师,需要你的帮助文档 java8 api。 可否分享
我先对没有加get方法的users进行序列化,再反序列化的时候再去users类中添加get方法,进行反序列化的时候报错了,这是因为什么原因呢
为什么输入到输出会自己换行,输出到输入要自己添加换行呢
老师,守护线程是在哪个线程里面被设置,就随那个线程结束嘛?
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637