对大家有帮助的问答会被标记为“推荐”,看完课程过来浏览一下别人提的问题,会帮你学得更全面
老师看完面向对象后需要再看java300集深入学习吗
老师,这个synchronized放public前面和放public后面有什么区别吗?视频中是放后面的,我试了一下放前面发现运行结果一样的喔
我这里如果想要修改Collections.sort()默认的排序规则
代码应该怎么写?
package com.bjsxt.Collections; import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; public class TestCollections{ //Collections工具类的使用 public static void main(String[] args) { ArrayList<String> al = new ArrayList<String>(); //向集合中一次性添加N多个元素 Collections.addAll(al, "aello","corld","bava"); System.out.println(al); //排序 Collections.sort(al); System.out.println(al); } }
老师,代码没报错,运行为null,是我的图片有问题,还是代码缺了什么呢?
import javax.imageio.ImageIO; import java.awt.*; import java.awt.image.BufferedImage; import java.io.IOException; import java.net.URL; public class GameUtil { public static Image getImage(String path) throws IOException { BufferedImage img = null; URL u = GameUtil.class.getClassLoader().getResource(path); try { ImageIO.read(u); } catch (IOException e) { e.printStackTrace(); } return img; } public static void main(String[] args) throws IOException { Image img=GameUtil.getImage("images/plane1.png"); System.out.println(img); } }