Questions tagged as 'java'

2
answers

How to count how many times an item is repeated in an Array of unknown size?

How do I count how many times an item appears in an Array that I do not know the size of? The array was created from a .CSV.     
asked by 11.11.2014 / 00:45
3
answers

How to decrease the quality of an image in android?

I have a list of objects that have an array of images that are somewhat "heavy", at the beginning of the application I have a custom listView that presents an image (icone) of each object, I would like to decrease the quality of these images bec...
asked by 06.01.2015 / 00:23
2
answers

Pick up the first letter of the last name and last name?

I'm using the code below to get the first letter of the first and last name. It's working, but I see the following problem for a longer name: Example:    Carlos Eduardo Martins Rego Dutra public static void main(String[] args) {...
asked by 28.03.2017 / 14:56
2
answers

Format result of integer division

I have the following code in JAVA: private int metros = 1500, minutos = 60; System.out.println("Distância em km = "+(metros/1000)); System.out.println("Tempo em horas = "+(minutoa/60)); However what is displayed after the executio...
asked by 31.12.2016 / 12:00
2
answers

About method chaining. Why is giving nullPointerException?

I have the class Request: package teste; import java.util.ArrayList; import java.util.List; public class Pedido { List<Item> lista = new ArrayList<Item>();; Cliente cliente; public Pedido adicionarPedido(int qu...
asked by 14.11.2016 / 19:45
2
answers

Why does the comparison of different objects return true?

First code: Integer i1 = 1234; Integer i2 = 1234; System.out.println(i1 == i2); //false System.out.println(i1.equals(i2)); //true Although it seems that primitive types are being used, they are actually objects, so when these objects are co...
asked by 21.02.2017 / 22:38
4
answers

Creating base date using StringBuilder

I'm creating my database with class sqliteOpenHelper , passing DB creation by String through StringBuilder . The problem is that you are only creating the first table, and then you do not create the next table, in which case I...
asked by 10.11.2015 / 23:27
1
answer

Can I place two conditions / increments within the same loop?

I basically want to do this for (j = parametro, int k=0; j < parametro + 3, k<3; j++, k++) { previsoes[i] += valores[j] * pesos[k] ; }     
asked by 14.11.2017 / 16:34
3
answers

How to separate a number in two

How could I separate a number with decimals into two other numbers? The idea is: when entering a number in the terminal, for example 125,69, when passing the number to the code pull the first two houses (decimals 69) to one variable, and the rea...
asked by 20.03.2018 / 23:25
3
answers

How to concatenate string with null without explicitly verifying?

When I try to concatenate a String that is actually null with a valid string (eg "a"), I get the value nulla . See the example below: String a = "a"; String b = null; System.out.println(b + a); I wanted the output to be just...
asked by 29.06.2016 / 22:45