老师,为什么数据没有删除掉呢?
当我添加数据失败时,employees_id并没有按照顺序来排,而是空掉那条数据,这是跟自动增长有关吗?怎么解决。
和视频不一样?不应该是异常在1和2之间吗?
老师这两个是一样的意思吗,是不是都能达成编码的统一
老师,请看“写入数据”这两行代码,注释就是我的问题,为什么write(bt)的结果不对呢,多了两个字节?
package com.bjsxt.io; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; /** * * 使用字节流读写和使用缓冲流读写的速度比较 * @author Administrator * */ public class TestCopy { public static void main(String[] args) throws IOException { //搭建桥梁:新建对象 //1.数据源,bb.txt内容是abcdefg FileInputStream fis = new FileInputStream("d:/eclipse-workspace/bb.txt"); //2.目的地 FileOutputStream fos = new FileOutputStream("d:/eclipse-workspace/cc.txt"); //读取数据 byte[] bt = new byte[3]; int len = 0; while((len=fis.read(bt))!=-1) { //写入数据 fos.write(bt,0,len); //使用这条语句,复制后的cc.txt内容是 abcdefg.(这是正确的结果) // fos.write(bt); //而使用这条语句,复制后得到的cc.txt内容是 abcdefgef; (这是错误的结果) } fos.close(); fis.close(); } }
老师好:
下面代码中u1,u2,u3的id,name,psd都一样,u2运用toString()方法重写,u3没有用,为什么运行结果hashcode三者都不一样,u2不是应该和u1一样的么
代码:
public class User { int id; String name; String pwd; User(int id,String name,String pwd){ this.id = id; this.name = name; this.pwd = pwd; } public static void main(String[] args) { User u1 = new User(1001,"蔡徐坤","123456"); User u2 = new User(1001,"蔡徐坤","123456"); User u3 = new User(1001,"蔡徐坤","123456"); System.out.println(u1); System.out.println(u2.toString()); System.out.println(u3); System.out.println(u1==u2); //判断是不是同一个对象 System.out.println(u1.equals(u2)); //equals判断两个对象的“逻辑上的值是不是一样” } }
运行结果:
方法不是没有重载吗?
package com.xh01; import java.awt.*; import javax.swing.*; public class BollGame extends JFrame{ Image ball = Toolkit.getDefaultToolkit().getImage("images/ball.png"); Image desk = Toolkit.getDefaultToolkit().getImage("images/desk.png"); double x = 200; double y = 200; double degree = 3.14/3;//弧度,3.14 = 180°; //boolean right = true;//控制小球的水平移动方向; //绘制窗口 public void paint(Graphics g){ System.out.println("窗口被画了一次"); g.drawImage(desk,0,0,null); g.drawImage(ball,(int)x,(int)y,null); x = x + 10*Math.cos(degree); y = y + 10*Math.sin(degree); //碰到上下边界 if(y>501-40-30||y<40+40){ degree = -degree; } //碰到左右边界 if(x>856-40-30||x<40){ degree = 3.14 - degree; } /* if(right) { x = x + 10; }else{ x = x - 10; } if(x>856-30-40){ right = false; } if(x<40){ right = true; }*/ } //创建窗口 void launchFrame(){ setSize(856,501); setLocation(100,100); setVisible(true); //1s绘制25次 while(true){ repaint(); try { Thread.sleep(40);//1s = 1000ms,大约1s绘制1000/40=25次; } catch (InterruptedException e) { e.printStackTrace(); } } } public static void main(String[] args){ System.out.println("我的小游戏开始了"); BollGame game = new BollGame(); game.launchFrame(); } }
老师,我的代码运行起来,窗口放大是这样的,图片加载不出来
老师,我想用循环代码画圆圈,第一行10个 第二行9个 第三行8个一直循环到第7行3个圆圈 这种代码应该怎么敲
老师,1.我把获取输入流代码写成
byte[] buf=new byte[1024]; int len=0; while((len=is.read(buf))!=-1){ System.out.println(new String(buf,0,len)); }
结果就报SocketException异常,怎么回事2.这个换行\r\n什么意思啊,和\n,\n\r,\r有什么区别吗?
一:如下图几个异常无法解决
二:源码: package com.bjsxt.server; import javax.swing.text.Document; import java.io.File; import java.util.ArrayList; import java.util.List; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; public class WebDom4j<SAXReader> {//用于解析xml private List<Entity> entityList;//用于存储n多个entity,每个entity都是一个servlet-name和一个servlet-class private List<Mapping> mappingList;//用于存储n多个mapping,每个mapping对应一个servlet-name和一个url-pattern //取值和赋值方法 public List<Entity> getEntityList() { return entityList; } public void setEntityList(List<Entity> entityList) { this.entityList = entityList; } public List<Mapping> getMappingList() { return mappingList; } public void setMappingList(List<Mapping> mappingList) { this.mappingList = mappingList; } //构造方法 public WebDom4j() { entityList=new ArrayList<Entity>(); mappingList=new ArrayList<Mapping>(); } public Document getDocument(){ try { //1:创建SAXReader对象 SAXReader reader = new SAXReader(); //2:调用read方法 return reader.read(new File("src/WEB_INFO/web.xml")); } catch (Exception e) { e.printStackTrace(); } } }
老师好,为什么我的static变量序列化成功了。
老师,我的没有文本文档
老师,为什么studnet10表格里面,字段name的唯一约束删除不掉呢?
create table student10( id int(8), name varchar(20), sex varchar(2), score int(2) ); alter table student10 add constraint uk_student10_name unique (name); desc student10; alter table student10 drop index uk_student10_name desc student10
老师请问,我static文件夹下的css目录中导入的ego.css文件下面几行说有错,我完全是复制粘贴过来的,这个什么原因?应该如何修改?
谢谢
坦克大战中的这行代码有什么用,我试着将这一行注释成#号发现一样可以运行
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637