) | | StringUtil.isempty (Dbfilepath) | | 0 >= retrowsexpected.length) {logger.error ("parameter Error"); return false; }//Verify that you have created file DBFile = new file (Dbfilepath); if (dbfile.exists () | | dbfile.isdirectory ()) {Logger.error (dbfilepath + "database file already exists or has a folder with the same name"); return false; }//Read SQL file String sql = GetText (SQLPath, sqlfilecharsetname); "UTF-
); }}
It's written like this, and here's the question, why is the Add parameter an object?
The parameter type of the 1.add method is object, which makes it easy to receive objects of any type
2. The collection is stored in the reference and address of the object,
So we can also
//gets the length of the collection SOP ( "Length:" + list . Size ()); //Print
On the learning experience, the difference between set,list,map in Java, and the understanding of the Java collection is to think about arrays:Arrays are fixed in size, and the same array can only hold data of the same type (base type/reference type), and Java Collections store and manipulate a set of data that is not
Node (data);
current = Current.next;
}/* * method: Traverse the list, that is, print the input list * If the header node is empty, print null; * If the header node is not empty, let the current index of the list move to the end of the node and start over from the starti
Well, it's a pain in the egg. Code conversion problem: to the shape of the string as \XE9\XBB into Chinese ...
In Python we can print "\xe9\xbb\x84" directly,
In the shell we direct echo $ ' \xe9\xbb\x84 ' #echo-e ' \xe9\xbb\x84 ' is OK,
Note: You cannot directly echo $ ' \xde\xab ' |iconv-f gbk-t utf-8,
Because GBK words, \XE9\XBB is Hazel, the back of the \x84 only half word, will be an error or garbled,
and internal algorithm are changed, which is the iterator and Listiterator class in Java2. However, the function of enumeration is very limited, such as only in one direction, can only read but not change.Sample codeImport Java. Util. Vector;Import Java. Util. List;Import Java. Util. Iterator;Import
On the learning experience, the difference between set,list,map in Java, and the understanding of the Java collection is to think about arrays:Arrays are fixed in size, and the same array can only hold data of the same type (base type/reference type), and Java Collections store and manipulate a set of data that is not
content);//query out the first data and replace//Modifying Data//Document query = new document (); //query.put ("Age", 28); //Document update = new document (); //Document D = new document (); //d.put ("Birthday", New Date ()); //d.put ("name", "Zhangsan"); //update.put ("$set", D); //mongocollection.updateone (query, update);//Modify the first piece of data to be queried//mongocollection.updatemany (query condition, modify content);//Modify all the data that is queried//Delete Data//Document q
. println (p. getAge ());}}}Convert the list object into a JSON string array The code is as follows:Copy code Package hb;Import java. util. Collections list;Import java. util. List;Import net. sf. json. JSONArray;Public class ListToJson {Public static void main (String [
)returnNodelast; Nodelast=Nodelast.next; } return NULL; } //change actions in a linked list Public voidChangeintNumintnumnew) { if(num)! =NULL) search (num). val=numnew; } //Delete a node of a linked list Public voidDeleteintnum) { if(num)! =NULL) searchprevious (num). Next=search (num). Next; } //Print linked
called, the number of arguments or the type of the method is unknown, which is called a mutable argument list. In previous Java code, you could use an object array to implement such a function. Because all classes are directly or indirectly inherited from the object class.Varargs.javaPackage sample; Class a1{}public class VarArgs {static void PrintArray (object[] args) {for (Object Obj:args)System.out.prin
sorting function calls an sort built-in function under the collection object. [very easy to use !]
1 // Collections. sort sorting 2 Collections. sort (number); 3 Collections. sort (word );
In this way, number and word are directly converted into a list in ascending order.
There is actually another way to sort by calling the compare function.
Complete program:
1 import java. util. arrayList; 2 import
Java Collections. sort () implements the default List sorting methods and custom methods [convert], collections. sort sorting
1. default list sorting method provided by java
Main Code:
List
List. add ("Wang Shuo ");
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
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
1. A simple implementation of a mutable parameter listWhen a method is called, the number of arguments or the type of the method is unknown, which is called a mutable argument list. In previous Java code, you could use an object array to implement such a function. Because all classes are directly or indirectly inherited from the object class. Varargs.java
Package sample;class a1{}Public class V
Java version linked list reverseDefine data Structures:/** * Data structure of the linked list */class Linkedlistarray { /** * value */ Object value; /** * Next node */ Linkedlistarray next = null; public void SetValue (Object value) { this.value = value; } public void Setnext (Linkedlistarray next) { this.next = next;
);
7. How do I delete the duplicate elements in ArrayList?If you don't care about the order of elements in ArrayList, you can drop the list into the set to remove the repeating element and then put it back in the list.
123
SetnewHashSetlist.clear();list.addAll(set);
If you care about the order of elements in ArrayList, you can use them LinkedHashSet .
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.