arraylist

Sending ArrayList<Object> through socket. Java

谁说胖子不能爱 提交于 2019-12-31 07:29:50
问题 What i'm trying to do is to send and ArrayList through a socket from Android client to Java server. Here is the code of client which sends the ArrayList : private void sendContacts(){ AppHelper helperClass = new AppHelper(getApplicationContext()); final ArrayList<Person> list = helperClass.getContacts(); System.out.println("Lenght of an contacts array : " +list.size()); // for (Person person : list) { // System.out.println("Name "+person.getName()+"\nNumber "+ person.getNr()); // } handler

compare 2 lists in java [closed]

不羁岁月 提交于 2019-12-31 07:26:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 years ago . I am getting data from the two different databases and storing them in the java.util.List Elements of database:1 column 1 column 2 **Investment Number** Investment Name 123 abcwe 124 agsdf 454 lkjcv 784 ojncv 478 hfdgh 852 qweyu 745 mmkty 201 pbckl 560 jklfg 741 nbvbn storing them in list1 Elements of database:2

Return List/Array from unmanaged C# DLL

拈花ヽ惹草 提交于 2019-12-31 07:13:07
问题 I have Unmanaged C# DLL: [DllExport(ExportName = "GetStudentsList", CallingConvention = CallingConvention.StdCall)] static public List<StudentsStruct>GetStudentsList() { return List<StudentsStruct>; } [DllExport(ExportName = "maxElement", CallingConvention = CallingConvention.StdCall)] static public int maxElement(int a, int b) { return c; } I want to return List<StudentsStruct> from the function. And I want to run above function in a C++ Application: using GetStudentsListFn = List

How to sort ArrayList while implementing Parcelable

和自甴很熟 提交于 2019-12-31 07:08:06
问题 I am trying to sort the category arraylist with Collections.sort method but have no luck with it. Here is my code: public class Categories implements Parcelable { private ArrayList<Category> category; private Recent recent; public ArrayList<Category> getCategories() { return this.category; } public void setCategory(ArrayList<Category> category) { this.category = category; } public Recent getRecent() { return this.recent; } public void setRecent(Recent recent) { this.recent = recent; }

How to sort ArrayList while implementing Parcelable

霸气de小男生 提交于 2019-12-31 07:06:25
问题 I am trying to sort the category arraylist with Collections.sort method but have no luck with it. Here is my code: public class Categories implements Parcelable { private ArrayList<Category> category; private Recent recent; public ArrayList<Category> getCategories() { return this.category; } public void setCategory(ArrayList<Category> category) { this.category = category; } public Recent getRecent() { return this.recent; } public void setRecent(Recent recent) { this.recent = recent; }

newbie attempt to use Java ArrayList to store ResultSet obtained from database

十年热恋 提交于 2019-12-31 07:04:11
问题 I have a database server communicating with a Java application server using JDBC. I want to store data from the database ResultSet into Java variables. Here's my Java class, HRPeople: public class HRPeople { public int elements; public String[] FirstName; public String[] LastName; public String[] Email; public int[] Salary; } I currently use this class to store data from ResultSet, as follows: query = "SELECT first_name, last_name, email, salary FROM HR.Employees where rownum < 6"; rset =

How to initialize arraylist which store in a Pojo class in another activity?

会有一股神秘感。 提交于 2019-12-31 06:57:07
问题 I want to store the data in a ArrayList and access it in another class,but when when I access the arraylist ,the arraylist.size() is 0.Means I didn't access the same arraylist. Somebody please tell me what I doing wrong. Here is my POJO class public class item { private String name; private String body; private String profileImage; public Item(){ } public Item(String body,String name,String profileImage){ this.body = body; this.name = name; this.profileImage = profileImage; } //Getter and

How to make this code work without repeating the numbers? [duplicate]

这一生的挚爱 提交于 2019-12-31 05:42:26
问题 This question already has answers here : Randomize a List<T> (19 answers) Closed 6 years ago . I need to print numbers from 1 to 50 in random order without repeating it . static void Main(string[] args) { ArrayList r = new ArrayList(); Random ran = new Random(); for (int i = 0; i < 50; i++) { r.Add(ran.Next(1,51)); } for (int i = 0; i < 50; i++) Console.WriteLine(r[i]); Console.ReadKey(); } 回答1: All you need to do is this check if the number already exists in the list and if so get another

How to make this code work without repeating the numbers? [duplicate]

为君一笑 提交于 2019-12-31 05:42:06
问题 This question already has answers here : Randomize a List<T> (19 answers) Closed 6 years ago . I need to print numbers from 1 to 50 in random order without repeating it . static void Main(string[] args) { ArrayList r = new ArrayList(); Random ran = new Random(); for (int i = 0; i < 50; i++) { r.Add(ran.Next(1,51)); } for (int i = 0; i < 50; i++) Console.WriteLine(r[i]); Console.ReadKey(); } 回答1: All you need to do is this check if the number already exists in the list and if so get another

required java.util.ArrayList<String>,found java.lang.Object : I do not understand the reason for this error

随声附和 提交于 2019-12-31 05:25:09
问题 Following are some snippets from a jsp page: <%! ArrayList songList = new ArrayList<String>(); %> <% songList = StoreSongLink.linkList; // linkList is a static variable in the class StoreSongLink // There the linkList is defined as public static ArrayList<String> linkList = new ArrayList<String>(); %> <%} else { for (ArrayList<String> list : songList){} %> The code inside the else srciplet produces an error required java.util.ArrayList<String> found java.lang.Object . Why is this ? I do not