Calculation of type 1.long databefore writing about a time of small software, System.currenttimemillis () returned from January 1, 1970 to the present millisecond number, is a long type, need to add a number to this. For example:
Long curtime = System.currenttimemillis ();//Gets the current time long deadlinetime = curtime+ (30*24*60*60*1000);//long Deadlinetime30day = curtime+ (long) 30*24*60*60*1000;
The result of this calculation is wrong, because the computed result of 30*24*60*60*1000 is the constant of the integer type, which is out of range, so it will be truncated into an integer type. If you want the correct result, you need to add a cast (long) before this number
2. Use the Remove when the list is traversingin the list with a foreach traversal with list.remove () directly delete, then will be error, pop this exception concurrentmodificationexception. So how do you delete a collection element when you traverse it?
Using iterators to remove
iterator<object> Iterator = List.iterator (); while (iterator. Hasnext ()) { Object obj = Iterator.next (); Make Judgment iterator.remove ();} </span>
3.intent Pass ListThere are many methods on the Internet, this kind of pro-test easy to use. The General Pass is not a list of int or string, but a custom. Then you need this:you're going to pass the collection class:list<object> ListIntent.putextra ("Lalala", (Serializable) list); when accepted, use
list= (list<Object>) getintent (). Getserializableextra ("Lalala"); but your object needs to implement the Serializable interface, which basically doesn't change anything about your data class (anyway I'm just implements Serializable and nothing else changes ^0^)
4. Sorting of collection classesFor example to give a collection class list<yourobject> list sort, then need to let yourobject implement comparable interfacethen implement the CompareTo method. For example, by time, there is a date member in Yourobject, which is a string that stores the date. So just write it in the Compartto method.
@Overridepublic int CompareTo (Yourobject another) {return Date.compareto (another.date);} </span>
then the list<yourobject> list can be sorted by calling the sort method.