Big Data Java Foundation day job

Source: Internet
Author: User

Tag:java   list    collection    

import java.util.list;import java.util.arraylist;class listdemo{          @SuppressWarnings (value= "unchecked")     public static void  main (String[] args) {        list list = new  arraylist ();         list.add (;     )    list.add (New integer);         list.add (" One ")         list.add (New string (" one ");         list.add (New student ("One", ' M ',));         list.add (New student ("A", "F",));             student student = new student ();         student.setname ("threE ");         student.setsex (' F ');         student.setage (+);         list.add (student);                 list list_repeat  = new arraylist ();         list_repeat.add (; )        list_repeat.add (student);         boolean bool_list = list.containsall (list_repeat);//contains List_repeat collection          boolean bool_obj = list.contains (student);//contains Student objects          list.remove (0);//move out of the set No. 0 element          list.remove (student);//move out the elements of the student object in the collection         list.removeall ( list);//Empty set &NBSP;&NBSP;&NBSp;             system.out.println (Bool_list) ;         system.out.println (Bool_obj);         system.out.println (List.size ());         System.out.println ("----------");                 student s = null;        for ( Int i=0;i<list.size (); i++) {            if ( List.get (i)  instanceof student) {                 s =  (Student) list.get (i);                 system.out.println ("Name:"  + s.getname ()   +  ", Sex:"  + s.getsex ()  +  ", Age:"  + s.getage ());             }else{                 system.out.println (List.get (i));             }        }    }}class student{     private String name;    private char sex;     private int age;    public student () {    }     public student (string name,char sex,int age) {         super ();        this.name =  name;        this.sex = sex;         this.age = age;    }    public void setname (String name) {         this.name = name;    }     public string getname () {        return  this.name;    }    public void setsex (char sex) {         this.sex = sex;    }         public char getsex () {         return this.sex;    }    public void setage (int  age) {        this.age = age;    }         public int getage () {         return this.age;    }} 


This article is from the "Forest Sensitive" blog, please be sure to keep this source http://senlinmin.blog.51cto.com/6400386/1774387

Big Data Java Foundation day job

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.