Posts by ldeoliveira • 2,015 points
38 posts
-
2
votes0
answers82
viewsQ: Associate final variable to another reference in lambda expression
I was developing a code that uses lambda expressions, where variables outside the scope of the expression should be declared as final. Then the doubt arose: I can associate the variable declared as…
-
3
votes1
answer936
viewsQ: When to use Collections.emptyList()?
I thought I’d use List<Object> lista = Collections.emptyList(); to initialize a list. But when I try to do lista.add(element) I get a UnsupportedOperationException. After researching a little,…
-
0
votes1
answer34
viewsA: Dependency is not added to clojure project
The problem is the incorrect name of the package in the file core.clj. To resolve, replace (:import (org.apache.commons.langr StringUtils))) for (:import (org.apache.commons.lang3 StringUtils)))…
-
0
votes1
answer34
viewsQ: Dependency is not added to clojure project
I’m learning Clojure and created a simple spellchecker project. In this project, I would like to use the Stringutils class from Apache Commons, so I added the following lines of code to import it…
-
8
votes2
answers540
viewsQ: How does an index improve the performance of a query?
Why does creating an index improve the performance of a query? Is any change made to the table structure? Is the data structure for disk storage modified? Is the algorithm used to perform the search…
-
8
votes2
answers941
viewsQ: Import multiple classes from the same package
I wonder if there’s any significant difference in making import java.util.* instead of import java.util.ArrayList; import java.util.Collection; import java.util.Date; import java.util.List; import…
-
2
votes2
answers417
viewsA: Vagrant error up windows 10
Hello, The problem is probably the configuration of the DNS server on the operating system within your Vagrant box. To resolve, run the following commands: auto eth0 iface eth0 inet dhcp dns-search…
-
26
votes4
answers1508
viewsQ: What is the difference between continuous integration and continuous delivery?
They are two widely used terms, and often even as synonyms. But what is the difference between them (if any)? What are the most common tools used in both scenarios?
-
0
votes4
answers7937
viewsA: How can I increment a day to a Java date?
With java 8 you can do it like this: LocalDate hoje = LocalDate.now(); LocalDate amanha = hoje.plusDays(1);
-
8
votes1
answer213
viewsQ: What is software architecture?
What the term "software architecture" means and how the term differs from "software engineering"?
-
2
votes2
answers11631
viewsA: Subtract JAVA dates from picking the days difference
Now, with the standard Java 8 Apis, you can do: LocalDate dtToday = LocalDate().now(); LocalDate dtEngravidou = Mommy.getDtPregnantDate(); long diasDeGravidez = ChronoUnit.DAYS.between(dtEngravidou,…
javaanswered ldeoliveira 2,015 -
3
votes1
answer281
viewsQ: Find out which branch has a certain tag - Git
I have a repository with several branches, and each branch has several tags. I want to find out which branch has a certain "name_da_tag". How can I do that?
gitasked ldeoliveira 2,015 -
0
votes1
answer53
viewsA: Code updates not running during Debug, Eclipse
I have been through something similar several times, the problem was always that the project had to be re-deployed (deploy again) on the application server. In this case, it is good to give a…
-
0
votes1
answer119
viewsA: Spring Batch Skippolicy, what’s it for?
According to the documentation, a class that implements the interface SkipPolicy shall determine a criterion for when a processing (Step) must be executed or not. The interface has the method…
-
0
votes1
answer217
viewsA: How to capture more than one attribute from a foreign key?
There are some properties that all relational databases should respect, are the ACID properties: Atomicity: all steps of a transaction must occur. If one step does not occur, no other occurs.…
-
6
votes2
answers382
viewsQ: Which means [] in angular.module
I’m a beginner in Angularjs and started reading about modules in an application. When I want to create a new module, I write the following line of code: var myAppModule = angular.module('myApp',…
-
5
votes1
answer1435
viewsQ: What’s the Youtube show for?
If I don’t declare that constant (serialVersionUID) in a class that implements the interface Serializable, I get a Warning. But what is this constant for anyway? Its value interferes with the…
-
6
votes2
answers592
viewsQ: Better performance for few accesses: Hashmap or Treemap?
I use the structure a lot java.util.HashMap<K,V> even for small scopes with few inputs (up to 50). But I’ve been wondering if the structure java.util.TreeMap<K,V> would not be better for…
-
6
votes2
answers720
viewsQ: Can memory leak occur in Java?
In the C language, for example, memory leaks are common because the responsibility for shifting memory lies with the programmer. In the example below (taken from Wikipedia) we can see a classic…
-
21
votes1
answer1449
viewsQ: What are the SOLID principles?
Lately, I’ve heard a lot about the term but for me it’s never clear if it’s a Pattern design or good practice in object orientation. Maybe it’s a very broad question, but why SOLID is useful and…
-
2
votes2
answers98
viewsQ: Evaluation of conditional expressions in Java
I’ve been observing that conditional expressions in Java that are formed only by literals or constants (or operations between them) are evaluated in different ways. Therefore, the code below…
-
1
votes3
answers3802
viewsA: Load a list of Enums
Change your method to: public List<String> carregarAtributos() { List<Atributos> lista = Arrays.asList(Atributos.values()); List<String> retorno = new List<String>(); for…
-
11
votes1
answer1208
viewsQ: Why String objects are immutable?
Up to the latest stable version, Java 8, type objects String are immutable. That is, any change in a String causes the creation of a new object String. This is not harmful from a performance point…
-
1
votes4
answers930
viewsA: Behavior of different ways of comparison in Java
"Here it is always printed that is not equal, so I believe that I am comparing correct references?" Correct. "My other question is whether this matches the code above that was typed" It is not the…
-
10
votes5
answers14272
viewsQ: Add all the latest changes to the commit in git
Whenever I make several changes to files in Git, I go out by adding the changes one-by-one through the git add. It’s a bit of a boring process, I wonder if you have a command to add all the "not…
gitasked ldeoliveira 2,015 -
2
votes3
answers441
viewsQ: How to concatenate string with null without explicitly checking?
When I try to concatenate one String which, in fact, is null with a string valid (e.g., "a"), get the value nulla. See the example below: String a = "a"; String b = null; System.out.println(b + a);…
-
0
votes1
answer64
viewsQ: Handling PHP compressed files
I need to solve the following problem with PHP: the user will upload a zip file containing hundreds (possibly thousands) of files. I must unzip these files into a certain directory and after that I…
phpasked ldeoliveira 2,015 -
2
votes2
answers357
viewsQ: Java Generics: Unknown wildcards and T
I was able to verify that in Java we can use both a Unknown wildcard ("?"), and "T" (what is this called?) to create generic mechanisms (classes, methods, interfaces...). But it was not clear to me…
-
4
votes3
answers1646
viewsQ: Java Maps: take key from value
Hello, I have a string map for string: Map<String,String> myMap = new Map<String,String>(); with a series of values myMap.put("1","valor1"); myMap.put("2","valor2");…
-
0
votes1
answer124
viewsQ: Problem to install RPM on Ubuntu
I’m trying to install some packages RPM in my Ubuntu, but I am getting dependency failure messages. The strange thing is that all dependencies are already installed in my ONLY. I created a directory…
-
1
votes2
answers463
viewsQ: Display empty directories only with the ls command
Hello, I’m a beginner in Ubuntu and would like to know if there is any way to display only directories that contain subdirectories or files on the command line. If I just type ls, appear…
-
16
votes4
answers4276
viewsQ: Should I initialize strings (or objects in general) with null?
I have noticed that a common practice among programmers is to initialize an attribute of a class with null. Is this good practice or not? Is there a difference between initializing with null or not…
-
2
votes1
answer2831
viewsQ: What are Java daemon threads and when to use them?
From the Java documentation I follow the following excerpt: The Java Virtual Machine exits when the only threads running are all daemon threads. But it’s still unclear to me when to set a thread as…
-
2
votes1
answer187
viewsQ: INNER JOIN performance in SQL
Hello, would anyone know me if there is any significant difference in performance in the two ways of doing INNER JOIN below? Way 1: SELECT column_name(s) FROM table1 INNER JOIN table2 ON…
-
9
votes2
answers450
viewsQ: Static blocks, heritage and constructors in Java
Hello, during my studies in Java I came across the following question Given the code below: class Foo extends Goo { static { System.out.println("1"); } { System.out.println("2"); } public Foo() {…
-
1
votes4
answers582
viewsA: How do I SELECT then INSERT
You are using the object $result, but at what point is it instantiated? I believe you should use the method rowCount() of the object $query. For more information on the method rowCount() see the…
-
12
votes1
answer2480
viewsQ: Differences between Java application servers
I would like to know the main differences between Glassfish, Jboss and Apache Tomcat application servers. Is there any specific aspect I should check before choosing one to start development? Are…
-
1
votes1
answer300
viewsA: What is the endpoint interface in EJB?
Hello, An endpoint interface is a resource used in a web service to identify the location of an interface. In clear English, endpoint is the address where an interface is exposed and has the format…