zoukankan      html  css  js  c++  java
  • 集合中存储的是对象么

    集合中存储的是对象么
    集合中存储的实际上是对象的引用

    import java. util.ArrayList ;
    import java. util.List ;

    class Apple{
        private String color ;
        private String type ;
        public Apple (String color, String type) {
             super();
             this.color = color;
             this.type = type;
        }
    }

    public class Main {
        public static void main (String[] args) {
            Apple apple1 = new Apple("red" ,"type1");
            Apple apple2 = new Apple("green" ,"type2");
            List <Apple> apples = new ArrayList<Apple>(4 );
            apples .add( apple1);
            apples .add( apple2);
        }
    }






  • 相关阅读:
    Oracle 创建dblink
    好的博客
    Java项目导出war包 security alert:integrity check error”
    tomcat7.0 处理问题
    项目支持Servlet3.0的新特性
    oracle replace函数
    JavaWeb项目连接Oracle数据库
    LeetCode OJ
    LeetCode OJ
    LeetCode OJ
  • 原文地址:https://www.cnblogs.com/ZhangJinkun/p/4531636.html
Copyright © 2011-2022 走看看