Questions tagged as 'java'

1
answer

How to sort an ArrayList in ascending order by date

I need to sort a ArrayList in ascending order by date. Because I am adding values out of order in it. In my ArrayList has only two fields in each element: data and valor . Does anyone know of any method I can use?    ...
asked by 28.03.2018 / 01:47
1
answer

How to call a method inside another method?

I'm developing a quiz. Using RadioButton as Answer. So far I created using the onClick method on each RadioButton, but it is not effective. So I would like to call each question ask1(); , ask2(); within the rate(View view)...
asked by 08.01.2018 / 11:45
1
answer

How to create a tree with n children by node? [closed]

I would like to know how to implement a tree where each node can have n children? As in the example below: Only in this case would nodes be an instance of a class. EDITED I'm trying to do this with a ArrayList , but I'm...
asked by 30.03.2018 / 01:12
1
answer

More efficient way to use "expression" in improved "for" cycles

In the following ways, which one is the most efficient? ... //assumindo que o método pegaListaPessoas() pesquisa na base de dados todos as pessoas for (Pessoa pAux : pegaListaPessoas()) { //executo alguma coisa } or: ... //assumindo q...
asked by 09.09.2014 / 10:59
3
answers

Save value after the comma JAVA

Hello, I need to get a value after the comma to from it do some operations, for example, 175/10 = 17.5, I need to save this value .5 as 5. My number will always be divided by 10, can you help me please?     
asked by 12.12.2018 / 19:47
1
answer

NullPointerException at java.io.File.init (Unknown Source) in Java with Lucene

I'm getting the following error in my Java code Exception in thread "Thread-2" java.lang.NullPointerException at java.io.File.<init>(Unknown Source) at Indexador.indexaArquivosDoDiretorio(Indexador.java:42) at Princ$1$1.run(P...
asked by 28.03.2014 / 13:09
2
answers

Reading strings and saving them in arrays

I'm trying to make a program where salesperson names have to be read and have to be stored in an array. My biggest problem is that I do not know what the limit of names entered by the user is. So I used the while: public static void mai...
asked by 31.12.2018 / 16:50
1
answer

Exception in thread "AWT-EventQueue-0" java.lang.NumberFormatException: For input string: "8" [closed]

I was developing a simple java application using Swing, and I'm not sure what the error in my code is. Here is the code: private void btnVerificaActionPerformed(java.awt.event.ActionEvent evt) {...
asked by 25.12.2018 / 01:04
2
answers

How to pass CSV file data to an array in Java? [duplicate]

Ihavea.CSVfilewithseveralnumbersintwocolumns(1032,54832).Ineedtogetthesenumbersandpassthemtoavector.HowdoIdothis?ImadeacodetoimportthefileandIcandisplaythenumbers,butatthetimeofpassingthevaluestothevector,I'mhavingproblems.BelowiswhatIdid(Thi...
asked by 19.11.2018 / 00:33
1
answer

Collection of an Object doing calculations with BigDecimal

I have the ValueTotal attribute this value should be represented by the sum of all items in the Item class that are in the items list, I am trying to sum all items in the list that are BigDecimal, but when I execute the value is 0, that is,...
asked by 03.11.2018 / 19:27