Collection interface: Collection is the most basic collection interface, declaring a common method for Java collections (including set and list only). Both set and list inherit Conllection,map.
Methods for collection interfaces:
Boolean Add (Object O): Adding a reference to an object in the collectionvoid Clear (): Deletes all objects in the collection, that is
Listutils.java---function classPackage com.enable.common.utils;Import Java.lang.reflect.Field;Import Java.text.NumberFormat;Import java.util.Collections;Import Java.util.Comparator;Import Java.util.Date;Import java.util.List;/*** @author Yinaibang* In the list found in the database, it is often necessary to reorder the different fields. The general practice is to use a sorted field to re-query the database.* If not the database query, directly in the
1.Collection List Set Map differential memoryThese represent the collection in Java, where the main element is whether the elements are ordered, whether they can be repeated to distinguish between memory, in order to properly use, of course, there are synchronization differences, see the previous article related.
Ordered No
Allow elements to repeat no
Collection
Perform simple character and digit statistics on strings to explore the List function in java, javalist
Question:
Count the numbers and strings in a string and arrange them separately.
1. Numbers. Strings can be obtained from the keyboard.
2. Stored in list
3. count the number of digits and the number of strings
4. Output numbers and strings in ascending order
5.
1.Collection List Set Map differential memoryThese represent the collection in Java, where the main element is whether the elements are ordered, whether they can be repeated to distinguish between memory, in order to properly use, of course, there are synchronization differences, see the previous article related.
Ordered No
Allow elements to repeat no
Collection
Java. util
Interface list
All super interfaces:
Collection Iterable
All known implementation classes:
Abstractlist,
Abstractsequentiallist, arraylist,
Attributelist, copyonwritearraylist,
Sorted list,
Rolelist, roleunresolvedlist,
Stack, Vector
Method SummaryBoolean add (E)Add a specified element to the end of the
remove elements from collection while traversing edgesThe only correct way to modify collection while traversing edges is Iterator.remove() to use the method, as follows:
12345
Iteratorwhile(it.hasNext()){// do somethingit.remove();}
One of the most common error codes is as follows:
123
for(Integer i : list){list.remove(i)}
Running the above error code will report an ConcurrentModificati
1.:
Collection: (in util package)
Set: (preface, Element not repeatable)
List: (preface, repeatable; index by corner):
ArrayList: The underlying data type is an array, adding and deleting is slow, find (access) Fast
LinkedList: The underlying data type is linked list, additions and deletions fast, find (access) slow.
Vector: The underlying data type is an array; the elder level, thread safe, but additions
Linear tables, linked lists, and hash tables are common data structures. During Java Development, JDK provides a series of corresponding classes for us to implement basic data structures. These classes are in the Java. util package. This article attempts to explain the functions of each class and how to use these classes correctly through a simple description.CollectionShortlist│ Invalid parameter
Char
Auto-Boxing is a conversion of the Java compiler between the base data type and the corresponding object wrapper type. For example: Convert int to integer,double into double, and so on. The reverse is automatic unpacking.What does the method overlay (overriding) and method overloading (overloading) in 6.Java mean?Method overloads in Java occur when
The array,list in Java has not been known before. At the same time the use of set,map,list completely confused, until the reading of this article, explained very clearly.There is no collection in the world, (only the array reference C language) but someone wants it, so there's a set of people who want to have an array that can be automatically expanded, so there
Http://selives.blogbus.com/logs/27714366.html
Arraylist and vector use arrays to store data. The number of elements in the array is greater than that in the actual storage to add and insert elements. Both allow direct serial number index elements, however, data insertion is designed to move array elements and other memory operations. Therefore, index data is inserted slowly. Because vector uses the Synchronized Method (thread-safe), its performance is inferior to that of arraylist, the sort
through the Listiterator method of the list collection. */public class Listdemo {public static void main (string[] args) {//TODO auto-generated method stub//method_1 (); Method_2 ( );} public static void Method_2 () {//Demo list iterator ArrayList al = new ArrayList (); Al.add (""); Al.add ("03");/* *//in Iteration The process is ready to add or remove elements Iterator it = Al.iterator (); The iterator op
List and set analysis for two Java container classes
Author: Java research organization; Source: itworld Java article; Source:
The container class can greatly improve the programming efficiency and programming capability. In Java2, all containers are re-designed by Sun's Joshua Bloch, enriching the functions of
Tips"Effective Java, third Edition" an English version has been published, the second edition of this book presumably many people have read, known as one of the four major Java books, but the second edition of 2009 published, to now nearly 8 years, but with Java 6, 7, 8, and even 9 of the release, the Java language has
The collections in Java consist of three classes, set, list, and map, all in the Java.util package, and set, list, and map are interfaces that have their own implementation classes. The implementation class of set mainly has the HashSet and Treeset,list implementation class mainly has the Arraylist,map implementation c
List mapping tableA list is an element that a Java collection stores in a sequence and allows repeating elements. Users of this interface can accurately control the insertion of each element in the list. Users can access elements through their integer index and search for elements in the
, their hearts a happy, soon wrote the code. But a few days later, is not an offer, but refused to believe, so think not the solution. In fact, the reason is very simple, is that their code is not robust. The interviewer can find 3 ways to break the code.1. Enter the head pointer null. The program crashes because the code tries to access the memory that the null pointer points to.2. The total number of nodes in the list with head node is less than K.
comparison function:BOOL Comp (int a,int b){Return a>b;}Called When: Sort (Vec.begin (), Vec.end (), Comp), so that it is sorted in descending order.[II] in Java, the most common way is: using the ArrayList and list interface The Java collection is divided into three main types:Set (SET)List (lists)Map (map)To unde
Linear table, linked list, hash table is a common data structure, in Java development, the JDK has provided us with a series of corresponding classes to implement the basic data structure. These classes are all in the Java.util package. This article attempts to explain to the reader the functions of each class and how to use them correctly through a simple description.Collection├
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.