Set learning notes, set learning notes
I. Concepts
A set is a way to store objects. The collection contains addresses for convenient reference. JDK 1.2 is available.
Ii. Differences between a set and an array
Set is variable length, and array is
The topic of this chapter is to create and destroy objects: When to create and how to create objects, when to avoid creation, how to avoid creation, how to ensure that objects are destroyed in a timely manner, and how to manage the cleanup actions
Associated Arrays can be operated in two ways:
Insert a keyword and the corresponding value
Query the corresponding value by keywordTypical applications include DNS lookup.InterfaceThe interface for associating arrays is as follows:public
Comparable and Comparator in java
Comparable and Comparator in java
-Comparable Interface
Interface Definition
public interface Comparable
{ public int compareTo(T o); }
This interface only contains a compareTO () function,
Java --- 29 --- two methods for retrieving elements in Map, javamap deletes Elements
There is no iterator in Map. How do elements in Map be extracted?
There are two methods:
One is to use Set keySet ()
One is to use Set entrySet ()
KeySet:
Java object array sorting and java array sorting
Import java. util .*;Import java. io .*;
Public class Main {Static int [] dp = new int [1010];Public static void main (String [] args) throws IOException {Mouse [] mice = new Mouse [1010];FileReader
Java-based automatic numbering system (similar to automatic numbering in word)
Functional requirements:
1. Obtain the next number based on the number of chapters and the current title to meet the requirements of different levels of numbers, just
Lintcode: Subarray Sum, lintcodesubarray
Given an integer array, find a subarray where the sum of numbers is zero. Your code should return the index of the first number and the index of the last number.ExampleGiven [-3, 1, 2, -3, 4], return [0, 2]
Dark Horse programmer [TreeSet collection], dark horse programmer treeset
------- Android training, java training, and hope to communicate with you! ----------
TreeSet set
The TreeSet set is an ordered set implemented by TreeMap. The internal
Java Collection Framework summary (5) use of The--map interfaceMap is used to hold data that has a mapping relationship (key-vlaue). The key of map does not allow repetition, that is, any two key of the same map object is always returned false by
Define binary operation class Binarytree{class node{private node left;//index private node right;//index private comparable data;public node (comparable data) {this.data = data;} Binary data comparison, large placed on the right, small on the left
The TreeSet in Java is a subclass of set, and the TreeSet collection is used to sort the object elements, as well as to ensure that the elements are unique.So why does the TreeSet guarantee that the element is unique and how is it sorted? Look at
Tag: his date sorts list by str main UPD [] CLI time ()mode one : Use public static > void sort (list list) method sorts the list:Implements comparable in the list object to sort and override the CompareTo (method) public class Clickinfoimplements
Package arrays. compara;
Import java. util. arrays;
Public class student {Public static void main (string [] ARGs ){STU [] stus = new STU [] {New Stu (156,34, "ad "),New Stu (153,24, "cc "),New Stu (126,37, "AB "),New Stu (176,45, ""),New Stu (156,34
Java collections are mainly concentrated in two parts, one of which is java. in the util package, some are java. util. in concurrent, the latter defines a set of synchronization functions based on the former.
This article focuses on various
Java containers Refer to these classes as List,set,map. Because of the problem of translation, ask the collection, collection these refer to them are a few.ListArrayList Random Access FastLinkedList Insert Delete FastThis is a good understanding,
Same
Both comparable and comparator are used to implement object comparisons, sorting
To compare and sort objects, you need to implement comparable or comparator interfaces
Comparable and comparator are all Java interfaces.
We learn any kind of programming language, not to go to a non-purpose online to find too many tutorials, but first from the macro understanding of its basic concept of thinking, from the macro sense of its logic and abstraction, and then practice,
Voting City used: system.in, regular pattern,matcher, sorting interface comparable replication CompareTo sorting methodA class in the election monitor, according to the number of votes, and the highest number of votes on the first
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.