Questions tagged as 'java'

1
answer

Why should not iterate a hashmap?

I've been doing a project and one of my colleagues mentioned that iterating hashmaps is something to avoid and instead should use hashmap . However, I think the hashmap's versatility of being able to save strings as a key allows you to...
asked by 10.01.2018 / 21:25
3
answers

Builder builder?

I would like to understand why this class has two constructors and why one of them has everything inside this and not separate as in the other. Does that change anything? Normal constructor: public Conta(Correntista correntista, String...
asked by 24.06.2017 / 17:36
1
answer

Using Switch Case for Intervals

My teacher passed an exercise in which we should use the cases of a switch to handle intervals, he said strictly that we should use the switch and we can not use if nor while/do . I've tried the following code: switch(saldo)...
asked by 24.11.2017 / 18:17
1
answer

Are Java 8 lambdas and streams bringing more benefits beyond conciseness?

The only benefits I realize in the lambdas and streams of Java 8 are code savings and, as the case may be, better express the author's intent. Is that all? Is there any example code that uses one of these features and is it better not onl...
asked by 23.07.2017 / 16:32
3
answers

Assemble a single string with several strings of an ArrayList in Java

How can I get multiple Strings from an ArrayList in a simplified way and merge into just one string variable? I'm new to Java and I'm having trouble completing this change in a simplified way, avoiding long, unnecessary lines of code. List<...
asked by 17.06.2015 / 22:21
1
answer

Display a message when the ListView is empty

I have a ListAdapter that extends a BaseAdapter that works perfectly. When it is empty, I want a message to appear. Where to implement this validation?     
asked by 01.02.2014 / 19:45
1
answer

Checking string within string

How to tell if specific text is contained in a string ? example: String str = " Hello Word"; How do I check to see if the word "Hello" is contained in that string "str". And if the check is true, how do you edit it? If the word...
asked by 16.07.2015 / 03:04
4
answers

Advantages of the Inner Class

Since I started programming for Android (I believe due to Google examples), I have the habit of creating internal classes for features related to Activity . Example : If Activity connects to the database (and if the request is s...
asked by 13.01.2016 / 12:43
2
answers

Block android rotation [duplicate]

I've developed an android app but I just need it to stand and can not lie down ... What's the best way to block the rotation? Thanks     
asked by 19.11.2015 / 02:49
2
answers

Question and answer with if and else in Java

No matter what I answer, both "Yes" and "yes" only show ELSE . Where am I going wrong? package saudacao; import java.util.*; public class Saudacao { public static void main(String[] args) { System.out.println("Ola, bom dia, v...
asked by 25.05.2014 / 02:11