arraylist

Making text bold on a listview to a specify word dynamically

青春壹個敷衍的年華 提交于 2021-01-29 08:26:33
问题 I am trying to put color and bold up on a word that matches the word from a sentence in ArrayList items/value. what I have done so far is as below... so I have a String variable called filter "Hello" now I want to iterate through ArrayList itemList and find "Hello" from ArrayList items and make it bold and blue. String filter = "Hello"; String itemValue = "I just want to say Hello world! Hello"; itemList = new ArrayList<String>(); for(int i = 0; i<10; i++) { itemList.add("I just want to say

Adding thread product to array

亡梦爱人 提交于 2021-01-29 07:55:38
问题 I have to add the objects of a threadpool to an ArrayList , in order to count the total amount of objects my threadpool has created. For that I have created an ArrayList , and after I execute my threadpool I add the object to the ArrayList . My problem is that the new threadpools overwrite the existing object in my Arraylist and therefore the Arraylist will always stay the same size, no matter how many times the code is run. My ArrayList : protected ArrayList<Runnable> ComponentBuild = new

JDK8 performance of ArrayList compared to LinkedList

六眼飞鱼酱① 提交于 2021-01-29 03:30:32
问题 I am starting to see more and more benchmarks that demonstrate ArrayList crushing LinkedList in terms of performance for 'large' inserts example below: Gluelist Adding(1M) Elements (5 Tests Avg.) LinkedList: 174.8 milliseconds ArrayList: 76.4 milliseconds GlueList: 39.2 milliseconds Adding(10M) Elements (5 Tests Avg.) LinkedList: 8975.6 milliseconds ArrayList: 4118.2 milliseconds GlueList: 3320.1 milliseconds I ran similar tests on a RHEL 7.2 with JDK8.latest and saw similar results. I am

List as O(log(n))

醉酒当歌 提交于 2021-01-29 02:55:57
问题 I have to make a data structure with certain conditions. First these 4 functions must be in O(log(n)): insert(Object o) insert(int index, Object o) delete(int index) update(int index, Object o) Second: The data structure must implement java.util.List My issue is with the O(log(n)) and the List. There are a lot of trees that can do the operation in O(log(n)) (like BST, Red-Black Tree, AVL Tree), but how can these trees be indexed and how can the insert be anywhere? Setting this up as only a

sort an ArrayList with multiple conditions

丶灬走出姿态 提交于 2021-01-29 00:02:35
问题 say i have an array list MyArrayList<MYObject> myObject class looks like : public class myObject { String name; Int age; String : city; } and my dummy data looks like this : name : martin , age : 20 , city : NY name : felix , age : 19 , city : LA name : brian , age : 21 , city : NY name : brian , age : 19 , city : NY now i wanna sort myArraylist (which have the above data in it) in this order - name : felix , lastname : 19 , city : LA name : brian , lastname : 21 , city : NY name : martin ,

sort an ArrayList with multiple conditions

浪子不回头ぞ 提交于 2021-01-28 23:58:48
问题 say i have an array list MyArrayList<MYObject> myObject class looks like : public class myObject { String name; Int age; String : city; } and my dummy data looks like this : name : martin , age : 20 , city : NY name : felix , age : 19 , city : LA name : brian , age : 21 , city : NY name : brian , age : 19 , city : NY now i wanna sort myArraylist (which have the above data in it) in this order - name : felix , lastname : 19 , city : LA name : brian , lastname : 21 , city : NY name : martin ,

Java Generics List and ArrayList with and without Parameters

蓝咒 提交于 2021-01-28 13:10:35
问题 I'm reading about Java Generics. and I want to ask what is the difference between the following statements. 1: List<String> list = new ArrayList(3); 2: List<String> list = new ArrayList<String>(2); 3: List<String> list = new ArrayList<String>(); 4a: List<String> list = new ArrayList("A"); // why I can't use String? 4b: List<String> list = new ArrayList('a'); // but char works fine. I'm reading Java Docs on Generics and after that I need to ask the above questions because I didn't get exact

Java Generics List and ArrayList with and without Parameters

纵然是瞬间 提交于 2021-01-28 13:08:46
问题 I'm reading about Java Generics. and I want to ask what is the difference between the following statements. 1: List<String> list = new ArrayList(3); 2: List<String> list = new ArrayList<String>(2); 3: List<String> list = new ArrayList<String>(); 4a: List<String> list = new ArrayList("A"); // why I can't use String? 4b: List<String> list = new ArrayList('a'); // but char works fine. I'm reading Java Docs on Generics and after that I need to ask the above questions because I didn't get exact

List Map data in excel using java

白昼怎懂夜的黑 提交于 2021-01-27 20:01:24
问题 Need help! I am trying to code a simple function that could return the data from an excel source. I am trying to create a list of Maps of data from excel file but the list that I am getting has the same values. All value are the same. Here is my code: import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.xssf.usermodel.XSSFWorkbook; import java.io

Selecting objects from an ArrayList based on value of certain fields

青春壹個敷衍的年華 提交于 2021-01-27 16:46:00
问题 I have a Course class, which has fields of various types, with their respective getters and setters, such as: float percentage char courseLevel String courseName boolean takingNow I then have an ArrayList of course objects and a method: public <T> ArrayList<Course> getCourses(int parameterId, T value) { ArrayList<Course> res = new ArrayList<Course>(); switch(parameterId) { case COURSE_NAME: for(Course c: courseList) { if(c.getCourseName().equals(value) { res.add(c) } } break; .... //rest of