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);
        }
    }






  • 相关阅读:
    使用手机游戏的新闻推送
    win8.1 64位环境建设android开发环境
    LeetCode: Multiply Strings. Java
    Thread.join()分析方法
    字幕效果的幻灯片出现在网站上的图片
    JAVA技术交流群
    Android使得手机拍照功能的发展(源共享)
    领导基础课程
    Mysql开启远程连接方法
    mysql远程连接命令
  • 原文地址:https://www.cnblogs.com/ZhangJinkun/p/4531636.html
Copyright © 2011-2022 走看看