1,求Java的程序代码public class Test extend Threadpublic static void main(String[] args)int i=0;while(i<Integer.MAX_VALUE)System.out.println("第“+i+”秒");i++;sleep(1000);}}}我来翻译下嘿嘿public class Testpublic static void main(String[] args)System.out.println("Hello word!!!");//输出语句嘿嘿 }}public class Testpublic static void main(String[] args)System.out.println("Hello word!!!"); }}
2,求段简单JAVA的代码import java.io.*; public class Testpublic static void main(String s[])byte[] b1=new byte[3];byte[] b2=new byte[3];tryFile f=new File("F:\\\\11.txt");RandomAccessFile raf=new RandomAccessFile(f,"rw");long len=raf.length();raf.read(b1,0,3);String str=bytesToHexString(b1);System.out.println("前三个字节哈希码是:"+b1.toString());System.out.println("转换为十六进制后是:"+str);raf.seek(len-3);//raf.read(b2,(int)(len-3),3);b2[0]=raf.readByte();b2[1]=raf.readByte();b2[2]=raf.readByte();str=bytesToHexString(b2);System.out.println("后三个自己哈希码是:"+b2.toString());System.out.println("转换为十六进制后是:"+str);}catch(Exception e)} public static final String bytesToHexString(byte[] bArray)StringBuffer sb = new StringBuffer(bArray.length);String sTemp;for (int i = 0; i < bArray.length; i++)sTemp = Integer.toHexString(0xFF & bArray[i]);if (sTemp.length() < 2)sb.append(0);sb.append(sTemp.toUpperCase());}return sb.toString(); } }主要的除了转16进制,就是用RandomAccessFile的seek来快速定位倒数的三个字节的位置 。还有问题的话 , baiduhi我,随时在线
3,求Java程序代码这是什么变态题目,出题目的脑子有问题 。。// 反射import java.lang.reflect.InvocationHandler;import java.lang.reflect.Method;public class TTpublic void sayHelloWorld()System.out.println("hello word");}public static void main(String[] args)Class c = TT.class;tryObject obj = c.newInstance();Method m = c.getMethod("sayHelloWorld");m.invoke(obj,null);} catch (Exception e)e.printStackTrace();}}}// 动态代理import java.lang.reflect.InvocationHandler;import java.lang.reflect.Method;import java.lang.reflect.Proxy;public class HelloWord implements IHWpublic void sayHelloWorld()}public static void main(String[] args)HelloWord hw = new HelloWord();InvocationHandler handler = new HelloWordHandler(hw);IHW proxy = (IHW) Proxy.newProxyInstance(hw.getClass().getClassLoader(), hw.getClass().getInterfaces(),handler);proxy.sayHelloWorld();}}interface IHWvoid sayHelloWorld();}class HelloWordHandler implements InvocationHandlerprivate Object objOriginal;public HelloWordHandler(Object obj)this.objOriginal = obj;}public Object invoke(Object proxy, Method method, Object[] args)throws ThrowableObject result;doBefore();result = method.invoke(this.objOriginal, args);return result;}private void doBefore()System.out.println("hello word");}}/// 还有一个就是用EJB去写,这个我不会 。public class Testpublic static void main(String[] args)String[] s=new String[] StringBuffer str=new StringBuffer(); for(int i=0;i<s.length;i++) str.append(s[i]); } System.out.println(str); }}---------------------------------------------------------------------------------------------------------------------------package test;import java.util.HashMap;import java.util.Set;public class Testpublic static void main(String[] args)HashMap<Integer, String> map=new HashMap<Integer, String>(); map.put(1, "H"); map.put(2, "e"); map.put(3, "l"); map.put(4, "l"); map.put(5, "o"); map.put(6, " "); map.put(7, "W"); map.put(8, "o"); map.put(9, "r"); map.put(10, "d"); Set<Integer> set=map.keySet(); for(Integer key:set) System.out.print(map.get(key)); } }}-----------------------------------------------------------------------------------------------//先写个hello.txt文件,放在某个文件夹下,比如F:\下面,里面的内容为Hello Wordpackage test;import java.io.BufferedReader;import java.io.FileInputStream;import java.io.FileNotFoundException;import java.io.IOException;import java.io.InputStreamReader;public class Testpublic static void main(String[] args)FileInputStream fis = null; BufferedReader br = null; tryfis = new FileInputStream("F:/hello.txt"); br = new BufferedReader(new InputStreamReader(fis)); String str = null; trywhile ((str = br.readLine()) != null)System.out.println(str); } } catch (IOException e)e.printStackTrace(); } } catch (FileNotFoundException e)e.printStackTrace(); } }}瞎写了3种,这种题目变态【java的基本代码,求Java的程序代码】
推荐阅读
- 项目分析总结,项目的SWOT分析总结
- 苹果xr如何双开微信,Iphone上想用微信多开几个号怎么弄啊
- 编程安卓小程序下载教程,小程序如何下载安装
- 2023年最值得入手的平板电脑,现在买平板具体选择哪款好
- 安卓的python,安卓手机系统支持Python手机编程吗
- 如何正确关闭云服务器? 云服务器怎么关机吗
- 有哪些手机编程软件,有没有手机上用的编程软件
- 手机数据恢复精灵免费版,有哪些好用的手机数据恢复软件免费版
- c语言好学吗要学多久,计算机C语言难吗大概需要多长时间能学会