Posts by Filipe Miranda • 3,138 points
59 posts
-
6
votes1
answer441
viewsQ: What is the difference between Kotlin data class and Scala case class?
In Scala we have case classes, for example: case class Pessoa(nome: String, sobrenome: String) and in Kotlin we have data classes: data class Pessoa( val nome: String, val sobrenome: String ) What’s…
-
0
votes2
answers202
viewsA: How to optimally read a list of Arraylist dependencies?
Use a Functional Programming Style Within the question you made, there is only this language and programming that you put and another one facing Java 8. At the end I quote another option, but it…
-
6
votes2
answers1845
viewsA: How to recover the return result of a routine from within a Thread?
This functionality is achieved through the use of Threads pools, available in Java, from version 1.5 on Executors Framework Instead of creating a Thread, you create a Pool with a Thread, and submits…
-
0
votes2
answers10187
viewsA: Generate Boleto in Java
Try the jBoleto I have worked with jBoleto and it was simple to use, accredited to be a good candidate for your application. In this case, I think the most active is the same Stella, ie with greater…
-
2
votes2
answers557
viewsA: Question about initialized attributes in the constructor in Java
Is there any difference when I start an attribute of an object in class builder? Yes, by exposing only one constructor, with the attributes of the class you want to create, you can force those who…
-
8
votes1
answer2555
viewsA: Stream() and parallelStreams()
The Streams API available from Java 8, has come to bring several benefits, let’s first define the serial algorithm vs the parallel algorithm. I recommend reading this question, my answer seeks to…
-
14
votes2
answers14814
viewsQ: What is the difference between an XML file and an XSD file?
We know that these two types of files are correlated - .XSD e XML. What’s the difference between the two? What good is a .XML(Extensible Markup Language) and the .XSD? It is possible to work with an…
-
15
votes1
answer6209
viewsA: Differences between getClass(). getResourceAsStream() and getClass(). getClassLoader(). getResourceAsStream()
The difference between how the value passed as argument is interpreted is very subtle. Basically, you have two different methods: ClassLoader.getResourceAsStream() and Class.getResourceAsStream().…
-
1
votes1
answer145
viewsA: Monitor Directory with Java Web
Watch out for the Java version Yes, you can use it for a web application Yes, no problem, even because you are on the Java SE platform. Just keep in mind that the Java version, you should use at…
-
9
votes1
answer519
viewsQ: Synchronized in static methods, and in nonstatic methods
If I have a class, where I have two methods one static and the other not. Is the lock the same or not? How to do for the two sharing methods, the same synchronization mechanism, ie the same lock?…
-
5
votes1
answer19133
viewsQ: How to create a custom Exception/Exception in Java
Java, brings with it several ready-made Exceptions, Illegalargumentexception, Illegalstateexception, Runtimeexception, among others. Creating a Custom Java Exception? I have the following method -…
-
8
votes1
answer19133
viewsA: How to create a custom Exception/Exception in Java
Creating custom exceptions in Java is perfectly possible, and this practice is widely used by many frameworks, such as Hibernate, Spring, Struts and many others. The language for creating Exceptions…
-
3
votes1
answer143
viewsQ: How to not include Finally and still close IO Streams, Connections, Statements, and other Resources?
We know the need to close resources (files, connections, also called Resources) consumed in Java, such as OutputStream and InputStream. When we don’t close them, we create performance problems and…
-
2
votes1
answer143
viewsA: How to not include Finally and still close IO Streams, Connections, Statements, and other Resources?
We must use the language Try-with-Resources Also known as Try-with-Sourses statement, this trick is available from version 1.7 of the Java SE platform. Like? In the Try-with-Resources, we can write…
-
1
votes2
answers8637
viewsA: Maven build error - Could not resolve dependencies for project
Just below the comment <!-- Abstração para envio de e-mails --> Dependency is being defined as the following jar: simple-email:jar In your pom.xml you also define a Repository, where Maven…
-
0
votes1
answer228
viewsQ: Using Multiple Threads to Run a Faster Build on Maven
What the Maven offers in terms of parallelism for the execution of builds? If I execute one build in a machine with more than one processor, how can I take advantage of more resources for…
-
1
votes1
answer228
viewsA: Using Multiple Threads to Run a Faster Build on Maven
From Maven 3.x we can request that builds run with multiple Threads. Like? using the option -T [number of threads] we can define how many Threads we want to build, as well as determine how many per…
-
1
votes1
answer67
viewsQ: How to create a Weakhashset /Weakset in Java
The java.lang.ref package offers classes that model reference types in Java, such as Reference, Softreferece, Weakreference and Phantomreference. Still not familiar with these references in Java?…
-
1
votes1
answer67
viewsA: How to create a Weakhashset /Weakset in Java
To create a Weakhashset, just use the following method: Set<Object> weakHashSet = Collections.newSetFromMap( new WeakHashMap<Object, Boolean>()); Interestingly, the Collections class, is…
-
7
votes2
answers1375
viewsQ: What’s the difference between On heap and Off Heap in Java - JVM Memory
I would like an explanation determining the characteristics of On heap and Off heap Memory in Java. We know that Thread Stacks, the code of our application and the Buffers NIO are all allocated Off…
-
1
votes1
answer765
viewsQ: How to access the value of a private attribute in a Java class without a public method?
How can I access the value of a private attribute in a class, a class in another package, without using an access method, such as a getter? class Person{ private String name = "Someone"; } Why would…
-
11
votes1
answer27744
viewsQ: Concatenate Strings into Java Loops - Stringbuilder or '+'?
Java allows us to concatenate Strings in Java using only the operator '+' String str = "a" + "b" + "c"; It’s a simple way to do the job, and much less verbose than with Stringbuilder. But in cases…
-
17
votes1
answer27744
viewsA: Concatenate Strings into Java Loops - Stringbuilder or '+'?
According to JSL - Java Specification Language 15.18.1. String Concatenation Operator + The operator '+' offers the facility of being a single character to concatenate Strings, and its use is…
-
3
votes2
answers6836
viewsA: Edit object stored in an Arraylist
You must include the method equals and hashCode, writing in their class Contato: public class Contato { private String nome; private String email; private int telefone; /*getters e setters*/…
javaanswered Filipe Miranda 3,138 -
4
votes1
answer964
viewsQ: How to create a Java directory using NIO.2 - Java SE 7
The API java. is part of the Java SE platform since its version 1.4. Now, from Java 7, we have several new Enhancements in this API and new features, which provide better management of the file…
-
3
votes1
answer964
viewsA: How to create a Java directory using NIO.2 - Java SE 7
The class java.nio.files.Files brings with it much of these new features and facilities. In case of the need to create one or more directories, let’s see how the static methods…
-
6
votes1
answer361
viewsQ: How to Run Javascript in Java 8’s Nashorn Engine Programmatically
From Java 8 we have a new engine for Javascript execution, this is Nashorn. Which Java SE platform classes are involved in engine discovery and script execution? How to run Javascript through the…
-
6
votes1
answer361
viewsA: How to Run Javascript in Java 8’s Nashorn Engine Programmatically
The API that should be used to access the Nashorn Engine is javax.script The identifier for Engine access, "nashorn" - Remembering that the engine is available from Java SE 8, ie in previous…
-
2
votes1
answer732
viewsA: Difference between scheduleAtFixedRate and Schedule in the Scheduledexecutorservice class
The difference between these methods is as follows: Scheduledexecutorservice.Chedule When calling this method you must define a Runnable which is your task, the team that the action should be…
-
8
votes1
answer255
viewsA: Canonicalized Mapping and Weakreference
Hello @Reginaldo Soares, To properly understand the workings of a Canonicalized Mapping, let’s first understand the actions of the Garbage Collector and the reference types that exist in Java. In…
-
10
votes2
answers1619
viewsA: Multi-core Cpus - Why doesn’t my application use all the processor cores?
Serial Algorithm vs Parallel Algorithm To solve your problem, you will need to change your algorithm. Today what you have is an application that runs all your logic in a single thread that will be…
-
2
votes1
answer249
viewsA: How to set a timeout for a particular action in Java?
Hi @Luiz Ricardo Cardoso, As we speak what you need is Websocket Protocol. A technology not only very fun but also powerful. Here is the official link of the technology that is directly linked with…
-
9
votes3
answers9295
viewsA: Email verification in Java
The best way to validate an email is to apply a regular expression. Pattern as static member in your Email class create a static and final private member of the Pattern type private static final…
-
3
votes1
answer1666
viewsA: Proxy project default, why use?
@Felipe Jorge, Proxy, translated directly means attorney or representative. The most important thing is to understand the purpose to create a Proxy Object is to create a representative of another…
-
2
votes1
answer78
viewsQ: What is the Substitution Model in Scala - Replacement Model
Substitution Model - Replacement Model What is the concept behind? How It Works? What it affects the way we program in Scala
-
6
votes1
answer638
viewsA: Define method within the body of another method in Java
On the line cliente.getInetAddress().getHostAddress() First the client variable has this method getInetAdress(), he another object which in turn has another method getHostAdress() The technical term…
-
1
votes1
answer1878
viewsA: Run Time Java Method in Time - Run Periodically
I have already had to do something very similar to what you are requesting. Inside the application server Weblogic 10.3 of 10 in 10 seconds connect to a JMS Topic and consume messages from this…
-
1
votes1
answer427
viewsA: Graphics Generation Framework for a Desktop System in Java
A good framework for what you want is: Jopenchart http://jopenchart.sourceforge.net/ recommend this too: Chartfx for Java Desktop…
-
0
votes1
answer27
viewsA: How to use Microsoft Z3 in java?
So much Scala how much Java can be integrated with Z3. Recalling that Scala is one of the languages that run on Java Virtual Machine http://lara.epfl.ch/w/ScalaZ3 For Java, Leonardo Moura himself…
javaanswered Filipe Miranda 3,138 -
4
votes2
answers105
viewsA: Force every instance to have 2 attributes
@Ana, in addition to using the constructor, validates the methods, so you create invariants for your class and impose rules for the states your class may be in. In other words, it is not enough to…
javaanswered Filipe Miranda 3,138 -
18
votes2
answers70450
viewsA: Error trying to run Eclipse: Java was Started but Return Exit code =13
This is because you downloaded a 32-bit version of Eclipse and tried to run it with a 64-bit version of Java, and vice versa. Just download the version corresponding to your JDK and this will be…
-
5
votes1
answer479
viewsA: Validate array type attribute in an annotation
At first when you asked, I immediately remembered my own experiences making notes, and how I was frustrated when trying to create a note that had a validation against its possible values, so my…
-
3
votes2
answers413
viewsA: Problem with String.Split
The method String.split accepts a expressão regular not just a character. Moral of the story, you need a regular expression that ignores characters within () The expression will be this: (;|\(.*\))…
-
0
votes1
answer878
viewsA: Tool to Measure Java Software Performance
Yes, there is a way, yes, there is an API that I designed to meet that, using Aspect-Oriented Programming. I don’t want to go into details about the paradigm here, but we will meet your need. First…
-
0
votes1
answer58
viewsA: How to receive the return of a selected text in windows?
No, there are no classes for this feature within the Java SE or Java EE Platform. Which doesn’t mean you can’t build this functionality using Java, it’s perfectly possible. You will need to write…
-
2
votes1
answer275
viewsA: What are the features and functionality of Apache Struts?
Denis, Apache Struts, both 1 and 2, is a framework widely used in industry. Mainly as a solution for systems that benefit from the MVC architecture. No doubt, you will find many projects using it.…
struts2answered Filipe Miranda 3,138 -
4
votes1
answer1381
viewsA: When should I use the @Enableautoconfiguration annotation and how does it work?
Delfino, this note is part of the Project Spring-Boot, interesting project for those who want to develop Micro-services. One of its main features of Spring-Boot is to allow the Spring Application…
-
1
votes2
answers271
viewsA: How to render a String that is in this format yyyy-mm-dd HH:mm:ss.fff presentable
In the code below, I’m using a Simpledataformat This class will be responsible for storing the format and receiving the String objects to create the date in the desired format public class MainTest…
-
1
votes1
answer623
viewsA: Problems with date field in spring
Brunon, you will probably need to create a Propertyeditor How Spring Binds a Data/Field Request? What happens is that Spring doesn’t know how to convert this String that is shown on the screen -…
-
5
votes3
answers627
viewsA: Optimize Java method using the Scopes concept
Don’t program in a JIT-friendly way, let him do the work In a common hotspot, say, a widely used version in the industry, such as JVM 6, several features exist to allow the code you wrote to be…