Most voted "arraylist" questions
The Arraylist class is an implementation of the List interface that uses an array to store elements.
Learn more…257 questions
Sort by count of
-
23
votes2
answers8037
viewsArraylist x List
What is the difference of declaring ArrayList and List for lists in Java? What are the advantages of using one or the other?
-
6
votes3
answers390
viewsIs it possible to place objects in an Arraylist as soon as instantiated?
Doubt applies not only in one ArrayList, but in any kind of List. It is possible to add objects to ArrayList soon after we instantiate it, and without having to use the method add()? As can be done…
-
6
votes4
answers2097
viewsPrint arraylist information on the screen
I have a ArrayList but I’m not being able to print the data on the screen. Follows class: public class Cachorro { private String Raca; private String cor; private String nome; private String…
-
6
votes3
answers1428
viewsHow to define the comparison of equality between two objects present in an Arraylist?
How can I define the equality comparison behavior between two objects whose class is defined by me that are stored in an Arraylist object? Java nomecor. public class NomeCor { private String nome;…
-
5
votes2
answers1382
viewsRetrieve the first elements of an Integer list
I have a list ArrayList<Integer> list = new ArrayList<Integer>(); where I have over 40,000 records. I wonder if there’s a way to get only the first 10,000. I know you can make one for…
-
4
votes1
answer1947
viewsHow to extract Array from JSON into an object’s List type attribute
I am using the Flickr API to get the information from the images, which returns the following JSON:…
-
4
votes1
answer2157
viewsDifference hashmap and arraylist
Could someone explain to me the difference between HashMapand ArrayList?
-
4
votes3
answers288
viewsSearch for tuple in an array
I have the following vectors: a = [('FI', 'SE'), ('SE', 'DK'), ('DK', 'DE'), ('DE', 'PL'), ('PL', 'BY')] b = [['NL', 'DK', 0], ['NL', 'DE', 0], ['NL', 'BE', 0], ['FI', 'SE', 0.054]] I need to go…
-
4
votes1
answer57
views"illegal start of Expression" when compiling on CMD
I have the mini program, which I will show you next. When compiling at the command prompt, I got an error on line 47 which says: illegal start of Expression I have in the program a list of entries…
-
4
votes1
answer233
viewsPassing multiple parameters as an Array
I have a method that takes an unknown amount of parameters like an Array, thus: public void enviarCampos(String funcao, String... campos) { // Ação do método } To call this method do:…
-
4
votes1
answer888
viewsConverting String to Arraylist
I am receiving in my java code a variable with the following value String arquivo = "CNPJ;INSCRICAOESTADUAL;COD_IBGE;DT_OPE;VLR_CARTAO_CRED;VLR_CARTAO_DEB 35083840049;0;4312476;13/01/2018;0.00;66.00…
-
4
votes2
answers110
viewsHow to do for every time you pass "true", it print the entire instantiated object?
import java.util.ArrayList; public class Loja { private ArrayList<Produto> ListaDeProdutos = new ArrayList<>(); public void cadastrarProduto(Produto produto){…
-
4
votes2
answers3601
viewsHow to compare two different lists in Java?
I have two lists that share a common value between them. I wanted these selected objects to be filtered so that it is added to another list List<Objeto1> lista1 = new…
-
3
votes2
answers212
viewsProblems to delete repeated numbers in an Arraylist<String>
I’m having trouble getting repeated numbers out of a ArrayList, here is the code snippet: for( int i = 0 ; i < houses.size(); i++ ) { for( int j = 1; j < houses.size(); j++ ) {…
-
3
votes2
answers3170
viewsIs it possible to store an Arraylist in a Java database?
In the case of Banco de Dados using Java, it is possible to store an object ArrayList in a Banco de Dados MySql? If yes, how can I store this type of data? And how can I recover it from the Data…
-
3
votes3
answers1653
viewsArraylist for String with split
I’m trying to break the following ArrayList with a String: ArrayList<Funcionario> funcionarios = new ArrayList(); But when I instate the object, I add the values inside through my method and…
-
3
votes1
answer1325
viewsCreate Generic type in Arraylist to persist data
I’m having trouble understanding the concept of Dao and how I could create a specific type to store my data, I’m initially using a String Arraylist and need to adapt it to an Object Product…
-
3
votes3
answers606
viewsFind the element with the highest number
I’m doing a basic election system, but I have a problem telling which candidate was elected. In this case, I added three candidates (x, y, z) to a ArrayList, I put two votes on x, three on y and…
-
3
votes1
answer1613
viewsFind String in Arraylist
ArrayList<String> posicoes = new ArrayList<String>(); posicoes.add("Ricardo;01051509912;gmail"); posicoes.add("Renato;123456789123;hotmail"); posicoes.add("Rodrigo;09873923121;yahoo"); I…
-
3
votes4
answers1255
viewsIndex returning -1 in Java Arraylist
Good morning. For study purposes, I am making a simple application in Java RMI that simulates some operations (create account, check balance, debit etc.) on one or more accounts. For each account I…
-
3
votes2
answers6310
viewsSearching for an object inside an Arraylist
I created a class Conta and defined its attributes. Elsewhere in the code, I set values for its attributes and added it to a ArrayList, now I need to select it and print the value of one of its…
-
3
votes2
answers1129
viewsWhen can I use Static in class?
I know the use of methods static should be avoided, so I have a question and I do not know if it is right to implement a ArrayList as static, it is accessed by several classes and contains data from…
-
3
votes2
answers49
viewsMy arraylist is returning the same value on all "nodes"
This code should take all the elements of a login.txt file and put inside a user array. public ArrayList<User> takeAll(){ ArrayList<User> list = new ArrayList(); User u = new User();…
-
3
votes1
answer703
viewsNodejs - Problem sending a POST with object array
I’m using Nodejs + Mongodb, and I’m trying to send an array of Book, via method POST, but somehow it’s giving problem, because when using Postman and clicking Send, it just returns me: { "_id":…
-
3
votes2
answers548
viewsHow to create getter and Setter from Arraylist?
I am creating a question and answer game, with the attributes: question, correct answer and the ArrayList option (private ArrayList<String> opcao = new ArrayList<String>();). I need the…
-
3
votes0
answers153
viewsMatch of the contours
I created the program below, to make the correction of tests. https://gist.github.com/andreemidio/d2cdf3d301fd8df1677e9a315ff845f0 I was able to outline, identify the fillers, I need to match the…
-
3
votes1
answer508
viewsHow to know if there is an element in a List index without error?
I’m trying to give a get() in the indices of a ArrayList, so that if there is something in those positions, I add that value with something else. Only if there is no such index, I would add it.…
-
3
votes2
answers613
viewsConvert an Arraylist<String> into a String[]
I need to pass on the values that are in my ArrayList<String> for a String[] because I need to make a setInputData("INPUT",input). I mean, I want to convert the next ArrayList<String>…
-
3
votes1
answer69
viewsComparison of index (get) in Array List not working properly
I’ve been trying to compare a string (right answer) for an alternative question as an example in a project I’m developing, but I can’t succeed in all the different ways I try. The goal is that every…
-
3
votes1
answer293
viewsScan an Arraylist of objects and check an attribute of an object passed as parameter with an Arraylist
I am a beginner in Java and my teacher passed a list of exercises to practice, in a question I need to create a system that registers a user only if his email has not been registered before. A part…
-
2
votes1
answer437
viewsSave Arraylist to the external memory of an Android phone
have how to save an Arraylist by Fileoutputstream in the memory of an android phone? Or have some better method? For example: FileOutputStream fos = openFileOutput("Foto_Imovel",…
-
2
votes1
answer1025
viewsCalling an Arraylist from one Jframe to another
I need to call a ArrayList raised in a JFrame to another JFrame. In this case, the user would make a registration in one of the Jframes, called Registration, and from this would create the User…
-
2
votes1
answer349
viewsList of random numbers without repetition Android
I have an Arraylist with N items inside and I need to randomly group them into 2 sets of X items and the rest into another set. But none of them can repeat themselves. For example: my Arraylist has…
-
2
votes2
answers4781
viewsHow to store data from a. txt file in an object - Java
I am beginner in programming and am making a small application that should register products, delete, edit, organize, control inventory, cost price, selling price, profit margin, etc. So far I have…
-
2
votes1
answer173
viewsArraylist Comparator JSP Object
I’m having trouble implementing the Comparator method, to sort the Object Arraylist. I have an Enterprise class. Where I then create an Arraylist, which is filled from a content manager system. I…
-
2
votes2
answers241
viewsOrdering of all elements of a multidimensional array (array)
I need to sort the array below in alphabetical order using the numeric key: Array ( [AM] => Array ( [1] => Array ( [localidade] => Arena da Amazonia [cidade] => MANAUS [estado] =>…
-
2
votes2
answers428
viewsMultiple sorts with Arraylist
I have a question. I want to order the Arraylist person in different ways. <%@ page import= "java.util.*"%> <%! public class Pessoa implements Comparable<Pessoa> { String Nome;…
-
2
votes1
answer673
viewsDelete item from an Inioc 2 array
I’m having a hard time understanding how splice() works. I need to delete items from an array when I click on (x), e.g.: <ion-item *ngFor="let item of data"> <ion-grid> <ion-row>…
javascript html5 angular ionic2 arraylistasked 7 years, 8 months ago Henrique Mendes Silveira Rodri 367 -
2
votes1
answer46
viewsArraylist: Is that right or is there a better way to do it?
I know a bit of java, but now I’m venturing into C#, but a question came up here: In java we instantiated an Arraylist like this: ArrayList<Tipo> nomeArray = new ArrayList<>(); We…
-
2
votes2
answers2461
viewsDelete repeats of values in Arraylist
I got the following ArrayList<Integer>: ArrayList<Integer> sequencia = new ArrayList<>(); sequencia.add(2); sequencia.add(11); sequencia.add(12); sequencia.add(13);…
-
2
votes1
answer203
viewsError while removing Object from Arraylist
When I try to remove a int of arrayList he simply of error. Code: ArrayList<Integer> colors = new ArrayList<>(); colors.add(Color.rgb(119, 103, 141)); colors.add(Color.rgb(33, 10, 208));…
-
2
votes3
answers1139
viewsRetrieve/locate object in arraylist
I am making a small CRUD with the theme saving for study purposes. I created 3 classes: Save, Accounts and Canvas (UI Swing). On the screen I register an account with the attributes name, agency,…
-
2
votes1
answer52
viewsIn a list list, how to sum each item of each list with the item of its respective position?
For ex my list is: x = [[1,2,3,4,5],[6,7,8,9]] How can I create a new list so that its elements are the sums of the corresponding elements in each list? y = [1+6,2+7,3+8,4+9,5+0]…
-
2
votes4
answers479
viewsRemove object from an Arraylist
I have an arraylist of objects, and I need to remove an object from it as follows. I need this object to be removed if its box attribute stores the same value that was typed in mine TextBox. Why am…
-
2
votes1
answer3277
viewsHow to change item in an Arraylist index?
I’m having trouble with this array exercise: a) Create the Blocodenotes class that has an attribute ArrayList<String> called notes. Create methods to insert, remove and fetch notes. Create a…
-
2
votes1
answer110
viewsCheck the arrayList object at runtime
I have an arraylist with three positions. I added to the array, objects like Manager, Seller and Technician, respectively. Using the getClass, would like to know how do I know which object is in…
-
2
votes1
answer111
viewsI’m having trouble adding a new student to my arraylist
I am reviewing previous java matter and in the middle of reviewing arraylists I found it difficult to add a student to the list. Each student has the following fields: name, student type, course…
-
2
votes1
answer1245
viewsAdd Contacts to an Array List
I would like to add contacts in a ArrayList, but adding initial values to the attribute. First I created a class called contact , and I want to create a contact type Arraylist and I would like to…
-
2
votes1
answer638
viewsRead Json without "knowing" the JAVA keys
The problem is that I need to inform the professions and wanted it to be automatic to read the json without having to inform ocup[1] = "jornalista". I would like the json reading to be automatic. {…
-
2
votes1
answer1122
viewsBrowse Arraylist of object objects and compare c#
I was wondering how I can reuse the object I put into an array list because I can’t compare it to anything, and how I compare an object inside it to another, in this college program the goal was for…