Questions tagged as 'java'

1
answer

Java code works on Mac, but on non-PC

The following code works on my Mac and not on the pc. I really need to start working on the pc, so I appreciate any help I can get. I'm using Eclipse Java Oxygen on both platforms. Code: import java.io.BufferedReader; import java.io.File; i...
asked by 27.09.2017 / 11:07
2
answers

I do not understand why it does not work [duplicate]

I have a problem here, I do not know why this does not print anything. It does not have compilation errors, but it does not work. Students Class import java.io.PrintStream; public class Alunos { private String primeiro; private S...
asked by 14.06.2017 / 23:59
1
answer

Basic question in LinkedList - Java

If I have a LinkedList called List that has size equal to 0, can I add an element in position 4 of it, for example?     
asked by 09.06.2017 / 22:42
3
answers

Error in indexes of an array

I'm trying to make a selection sort algorithm, just to train algorithms myself, to my see my logic is right about sorting, but it's returning me an error I do not understand. > Code: import java.util.Scanner; import java.util.Arrays; publ...
asked by 27.12.2018 / 18:21
2
answers

How to get index of an advanced "for"?

I was wondering if I can get some kind of control variable from an "% advanced"%. " For example: On a normal for, I do this as follows: for (int i = 0; i < algumaCoisa.size() ou length; i++){ //código.. } this variable for...
asked by 27.07.2017 / 03:12
1
answer

Limit number of characters entered based on view width

I have the following EditText with width defined as match_parent , basically occupying the total width independent of the device: <EditText android:layout_width="match_parent" android:layout_height="wrap_content" an...
asked by 03.08.2017 / 22:46
2
answers

Add interest per parcel with BigDecimal?

I am creating a system where I need to calculate the interest and add the installments of a financing. For this, I'm using BigDecimal and I'm not able to perform the math operation following the rendering formula. How to do this? I'm t...
asked by 03.09.2016 / 20:54
1
answer

NullPointerException error while executing while [closed]

public List<Produto> read(){ Connection con = ConexaoMysql.conectar(); PreparedStatement stmt = null; ResultSet rs = null; List<Produto> produtos = new ArrayList<>(); try { stmt = con.prepareStatem...
asked by 15.12.2016 / 00:15
2
answers

Evaluation of conditional expressions in Java

I have been observing that conditional expressions in Java that are formed only by literals or constants (or operations between them) are evaluated in different ways. So, the code below compiles normally: public class Main { public static...
asked by 05.12.2016 / 22:32
1
answer

How to print sentences from the smallest to the largest?

I need to make a class that takes 3 user phrases and prints in order from the shortest sentence to the longest:    Make a program to read three user phrases and display on the screen the   three sentences in order of sentence size. For exampl...
asked by 06.10.2018 / 23:39