关于new class不是null

c#new一个类型的时候,不是null

例如:

classOne one = new classOne();

if(one != null)

{   data;//data是都可以进入的;也就是条件是true;

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
修改jar包中变量 或者长量 步骤如下: 1.用jd-gui打开该jar 怎么打开不用我说了吧? 打开之后找到 要修改提示信息 的class文件 这里找到的是GenEntity 找到对应需要修改的代码所在的方法名 我这里包含提示信息的这段代码在方法 getAllDataBase() 如下图: 2.用jd-gui或者winrar把GenEntity.class 解压出来到C盘 (目录无所谓) 3.双击桌面上安装好了的 jc lasslib bytecode viewer ,点击软件的 File -- Open Class File 打开你刚解压出来的class文件 4.点击methods--getAllDataBase--Code methods是表示方法不用说吧 getAllDataBase是刚在jd-gui里面找到的方法名 Code包含了getAllDataBase方法里所有的信息 找到"不能打开数据库连接,请检查!" 这里这个工具没有提供搜索功能 如果这里很多内容 那么你可以点击 copy to clipboard把这里的内容复制到一个文本文件里面然后再搜索 这里找到的是第82行 5.点击第 82行后面的 #34 会跳转到Constant Pool常量池的第34个常量 6.再点右边的 cp info #362 会跳转到第362个常量 这里能看到String: 不能打开数据库连接,请检查! 也就是最后输出的信息 7.找到GenEntity.class的关键常量了现在就该修改它了 在eclipse里面新建一个Test来处理GenEntity.class [java] view plain copy import java.io.*; import org.gjt.jclasslib.io.ClassFileWriter; import org.gjt.jclasslib.structures.CPInfo; import org.gjt.jclasslib.structures.ClassFile; import org.gjt.jclasslib.structures.constants.ConstantUtf8Info; public class Test { public static void main(String[] args) throws Exception { String filePath = "C:\\GenEntity.class"; FileInputStream fis = new FileInputStream(filePath); DataInput di = new DataInputStream(fis); ClassFile cf = new ClassFile(); cf.read(di); CPInfo[] infos = cf.getConstantPool(); int count = infos.length; for (int i = 0; i < count; i++) { if (infos[i] != null) { System.out.print(i); System.out.print(" = "); System.out.print(infos[i].getVerbose()); System.out.print(" = "); System.out.println(infos[i].getTagVerbose()); if(i == 362){ ConstantUtf8Info uInfo = (ConstantUtf8Info)infos[i]; uInfo.setBytes("芝麻不开门!".getBytes()); infos[i]=uInfo; } } } cf.setConstantPool(infos); fis.close(); File f = new File(filePath); ClassFileWriter.writeToFile(f, cf); } } 这里需要注意"C:\\GenEntity.class"是我存放class的目录 if(i == 362) 这里是刚我在第七步找到的常量序号 "芝麻不开门!"这里是我想修改的文字信息! 运行Test.java 会有如下提示信息 没有报错就证明正常的 如果报错那么就有问题 9.把C盘刚修改后的GenEntity.class替换掉原来的GenEntity.class 怎么替换不用我说了吧.. 用winrar打开.jar 然后把GenEntity.class拖进去覆盖就行了 10.运行效果..
import java.awt.*; import java.io.*; import javax.swing.*; public class diyiti1 { private JFrame frame; public static void main(String[] args) { diyiti1 that=new diyiti1(); that.go(); } public void go(){ int counta=0,countb=0,countc=0,countd=0,counte=0; JButton tapple,tbanana,tcat,tdog,tegg; FileInputStream a; String oldStr = ""; try { a = new FileInputStream("E:\\a.txt"); InputStreamReader br = new InputStreamReader(a); BufferedReader reader = new BufferedReader(br); String line = null; while((line = reader.readLine())!=null){ oldStr += line; } } catch (FileNotFoundException e1) { e1.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } char array[]=new char[oldStr.length()]; for(int j=0;j<5;j++) array[j]=oldStr.charAt(j); for(String c:){ switch(c){ case "apple":counta++;break; case "banana":countb++;break; case "cat":countc++;break; case "dog":countd++;break; case "egg":counte++;break; default:System.out.print("Wrong!"); } } frame=new JFrame("统计"); Container content=frame.getContentPane(); content.setLayout(null); tapple=new JButton("apple的个数"+counta); tbanana=new JButton("banana的个数"+countb); tcat=new JButton("cat的个数"+countc); tdog=new JButton("dog的个数"+countd); tegg=new JButton("egg的个数"+counte); //显示 tapple.setBounds(1,0,counta*100,20); tbanana.setBounds(1,20,countb*100,20); tcat.setBounds(1,40,countc*100,20); tdog.setBounds(1,60,countd*100,20); tegg.setBounds(1,80,counte*100,20); //图像 tapple.setBackground(Color.yellow); tbanana.setBackground(Color.red); tcat.setBackground(Color.blue); tdog.setBackground(Color.green); tegg.setBackground(Color.white); //botton颜色 content.add(tapple); content.add(tbanana); content.add(tcat); content.add(tdog); content.add(tegg); // frame.setSize(300,200); frame.setVisible(true); } }

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值