import java.net.InetAddress; import java.net.UnknownHostException; public class InetTest3 { public static void main(String[] args) throws UnknownHostException { //创建根据IP地址获取计算机信息的InetAddress对象 InetAddress inetAddress=InetAddress.getByName("182.61.200.6"); //返回ip地址 System.out.println(inetAddress.getHostAddress()); //返回计算机名 System.out.println(inetAddress.getHostName()); }
没返回计算机名?
为什么newThr解说是24怎么还写的是12
什么是“键”
这里不是等于空嘛,怎么是不等于空
老师macOS系统下载这个工具包要怎么下载啊
因为Set没有指定索引的位置,所以获取所有元素的时候只能用增强for来实现吗?
老师请问一下,这个sb.toString()的输出和sb的输出都是abcdefgh,那怎么样输出sb的地址呢?
这两句重复实例化对象为什么每次都要放在方法里面,一直重复为什么不放在外面呢?放在外面不是更节省内存?放在里面和放在外面有什么区别呢?或者是两者有什么优缺点?要是自己写代码怎么判断写里面还是外面?
package com.itbaizhan; import java.io.*; public class TestFileBufferStream { public static void main(String[] args) { long time1=System.currentTimeMillis(); copyFile("d:/1.jpg","d:/3.jpg"); long time2=System.currentTimeMillis(); System.out.println(time2-time1); } /** * sourse 源文件 * destination 目的地文件 */ public static void copyFile(String source,String destination){ //实例化节点流对象 try(FileInputStream fis=new FileInputStream(source); FileOutputStream fos=new FileOutputStream(source); //实例化处理流对象 BufferedInputStream bis=new BufferedInputStream(fis); BufferedOutputStream bos=new BufferedOutputStream(fos)){ int temp=0; while ((temp=bis.read())!=-1){ bos.write(temp); } bos.flush(); }catch (IOException e){ e.printStackTrace(); } } }
并没有生成3.jpg
通配符的上下限限定什么情况下使用?
老师,通配符的上下限限定可以同时使用吗?
老师,在开发中什么时候使用泛型类,什么时候使用泛型接口,什么时候使用泛型方法?
老师为什么这里会报错
老师,文档中typora的样式很漂亮,我用的也是typora,可以发一下老师的typora样式文件吗?
按照老师的步骤敲,加上synchronized方法后会报错java: illegal start of expression,仔细检查了下好像也没敲错,文档用的表示方式和老师敲的也不太一样,请问是为什么
class Programmer{ private String name; public Programmer(String name){ this.name = name; } public void coding() { synchronized (){ try { System.out.println(this.name + " double click Idea"); Thread.sleep(500); System.out.println(this.name+" Idea start"); Thread.sleep(500); System.out.println(this.name+" happy coding"); } catch (InterruptedException e) { e.printStackTrace(); } } } public void computer() { synchronized (){ try { System.out.println(this.name + " POWER ON"); Thread.sleep(500); System.out.println(this.name + " press on"); Thread.sleep(500); System.out.println(this.name + " system starting"); Thread.sleep(500); System.out.println(this.name + " System On"); } catch (InterruptedException e) { e.printStackTrace(); } } } } class Working1 extends Thread{ private Programmer p; public Working1(Programmer p){ this.p = p; } @Override public void run() { this.p.computer(); } } class Working2 extends Thread{ private Programmer p; public Working2(Programmer p){ this.p = p; } @Override public void run() { this.p.coding(); } } public class TestSyncThread { public static void main(String[] args) { Programmer p = new Programmer("Lee"); new Working1(p).start(); new Working2(p).start(); } }
非常抱歉给您带来不好的体验!为了更深入的了解您的学习情况以及遇到的问题,您可以直接拨打投诉热线:
我们将在第一时间处理好您的问题!
关于
课程分类
百战程序员微信公众号
百战程序员微信小程序
©2014-2025百战汇智(北京)科技有限公司 All Rights Reserved 北京亦庄经济开发区科创十四街 赛蒂国际工业园网站维护:百战汇智(北京)科技有限公司 京公网安备 11011402011233号 京ICP备18060230号-3 营业执照 经营许可证:京B2-20212637