zoukankan      html  css  js  c++  java
  • 自动装箱和自动拆箱

     1 package com.isoftstone.iics.bizsupport.epartner.fh;
     2 
     3 import java.util.ArrayList;
     4 import java.util.List;
     5 
     6 import org.junit.Test;
     7 import org.omg.CORBA.IntHolder;
     8 
     9 public class IntegerTest {
    10     
    11     /**
    12      * boolean char byte<=127 short int 介于-127--128会被包装到固定的对象中
    13      * 
    14      * 装箱和拆箱是编译器认可的,虚拟机只是执行字节码
    15      * <p>Title: test</p>
    16      * <p>Description: TODO</p>
    17      * @author 冯浩  2017年4月12日 上午8:15:36
    18      */
    19     @Test
    20     public void test(){
    21         List<Integer> list=new ArrayList<Integer>();
    22         list.add(1);
    23 //        list.add(Integer.valueOf(1));
    24         
    25         int q = list.get(0);
    26         int intValue = list.get(0).intValue();
    27         
    28         Integer a=100;
    29         Integer b=100;
    30         if(a==b){
    31             System.out.println("a==b");
    32         }
    33 //        IntHolder a=5;
    34         Integer a1=1000;
    35         Integer b1=1000;
    36         if(a1==b1){
    37             System.out.println("a1==b1");
    38         }
    39     }
    40     
    41     @Test
    42     public void test2(){
    43         int a=1;
    44         IntHolder b=new IntHolder(a);
    45         this.add(b);
    46         System.out.println(b.value);
    47         
    48     }
    49     
    50     public void add(IntHolder a){
    51         a.value+=1;
    52     }
    53 
    54 }

    枚举类测试

     1 package com.isoftstone.iics.bizsupport.epartner.fh;
     2 
     3 /**
     4  * 
     5  * <P>Description: TODO枚举类测试</P>
     6  * @ClassName: EnumTest
     7  * @author 冯浩  2017年4月12日 上午8:38:37
     8  * @see TODO
     9  */
    10 public class EnumTest {
    11     
    12     public static void main(String[] args) {
    13         Model value = Enum.valueOf(Model.class, "MW");
    14         String name = value.getName();
    15         System.out.println(name);
    16         
    17     }
    18 
    19 }
    20 
    21   enum Model{
    22       
    23       MW("1","梦网"),MD("2","漫道"),ALIYUN("3","阿里云");
    24       private String index;
    25       private String name;
    26     public String getIndex() {
    27         return index;
    28     }
    29     public void setIndex(String index) {
    30         this.index = index;
    31     }
    32     public String getName() {
    33         return name;
    34     }
    35     public void setName(String name) {
    36         this.name = name;
    37     }
    38     private Model(String index, String name) {
    39         this.index = index;
    40         this.name = name;
    41     }
    42       
    43     
    44 }
  • 相关阅读:
    非嵌入式数据库 软件很难普及 玩大
    FireMonkey下的异形窗体拖动(需要使用FmxHandleToHwnd函数转化一下句柄)
    公司开到高新技术区可以只收11的企业所得税,拿到软件企业认证后可享受所得税两免三减半(从盈利年度算起)
    猜测:信号槽的本质是使用Windows的自定义消息来实现的
    服务运行、停止流程浅析
    在线压缩JS的工具
    通用流程设计
    并行Linq(一)
    SQL基础知识总结(一)
    Easyui布局
  • 原文地址:https://www.cnblogs.com/nihaofenghao/p/6697581.html
Copyright © 2011-2022 走看看