Posts by StatelessDev • 2,534 points
98 posts
-
5
votes2
answers4147
viewsA: What is the difference between Embeddedid and Idclass in Hibernate?
There are people who advocate the fact that mapping with @EmbeddedId are more expressive and clear, because you can directly access the class that has the composite key, something that is not…
-
2
votes1
answer504
viewsA: How to retrieve IMEI from mobile programmatically?
The method getDeviceId() is deprecated, in fact, as pointed out by documentation, since API 26. Instead, use the method gethsemane(). final String imei = telephonyManager.getImei(); Not forgetting…
-
7
votes1
answer259
viewsA: What is the difference between Mkdir and Createnewfile?
One read in the documentation would be enough for you to answer your question: public boolean createNewFile() throws IOException Atomically creates a new, Empty file named by this Abstract pathname…
javaanswered StatelessDev 2,534 -
0
votes1
answer16
viewsA: Tomcat using all colors
According to this link, the following compiler configuration allows correcting this behavior: -Djava.net.preferIPv4Stack=true…
-
1
votes1
answer23
viewsA: Wrong code error in setType " non-static method setType(String) "
Your problem is here: Intent.setType("text/plain"); Intent.putExtra(Intent.EXTRA_TEXT, "COMPARTILHAR MEU APP"); When using Intent (the class name) and not intent (the name of the variable you…
-
1
votes2
answers351
viewsA: Problem with string comparison
One should always use the equals() when comparing the value of Strings. Use == brings confusion of this kind: String nome1 = new String("Marcela"); String nome2 = new String("Marcela");…
-
0
votes1
answer131
viewsA: Springboot does not render image (only if restarting)
The problem is that second this post, the briefcase static is only loaded on application startup by Spring Boot, any changes in the contents of this folder will only be reflected on the next server…
-
3
votes1
answer2248
viewsA: Non-static error method cannot be Reference
This happens because you have these two lines out of the method main: Personagem jogador = new Personagem(); Personagem inimigo = new Personagem(); When a class is instantiated (i.e., created with…
javaanswered StatelessDev 2,534 -
4
votes1
answer1893
viewsA: Doubt to create and work with JAVA class array
You have an array scope problem vetor. How he was created inside the for, it will exist only as long as the for is being executed and can only be accessed there too. Playing the line player[] vetor…
-
1
votes1
answer55
viewsA: Create a method that receives a generic class?
If I understand correctly, you don’t need a property Class<?> classe in your class Leitor. Just use in your logic the class informed in the method parameter itself leArquivo(...). Thus: 1) The…
-
6
votes2
answers972
viewsA: How to use Stream.reduce() appropriately
I believe what you need is groupingBy. Taking advantage of your list routes and passing as the grouping criterion a class property Route, in the case, getOrigem(): Map<String,…
-
3
votes1
answer191
viewsA: How to search using regular expression in Delphi 7
GPField.*IsNull The expression will be true for any character (.) which appears 0 or n times (*) amid GPField and IsNull, bringing the lines you mentioned in your question.…
-
1
votes1
answer187
viewsA: Is there any way to round a negative value to zero in Visualg?
How about replacing that: Se(vidaInimigo <= 0) entao EscrevaL("Vida: 0") senao EscrevaL("Vida: ", vidaInimigo) FimSe That’s why: Se(vidaInimigo < 0) entao vidaInimigo <- 0 FimSe…
-
0
votes2
answers352
viewsA: Difficulty with nested FOR loop
Another option. If you have any questions, just ask. I used some resources that maybe you haven’t studied yet to stimulate you to search and learn more. ;) public static void main(String args[]) {…
-
0
votes1
answer110
viewsA: Android Studio giving error
Close Android Studio and delete the following folder. It will be automatically downloaded by the IDE the next time you open it: macOS: ~/.gradle/wrapper/dists Windows:…
-
1
votes1
answer60
viewsA: Request access data when some data is wrong
See if this is what you need. Read the comments in the code and, if you have any questions, just ask. This is just one of the ways to solve your problem. public static void main(String args[]) {…
javaanswered StatelessDev 2,534 -
3
votes2
answers1052
viewsA: Cannot pass a null Grantedauthority Collection Spring Security
The problem is here, when returning null. @Override public Collection<? extends GrantedAuthority> getAuthorities() { // TODO Auto-generated method stub return null; }…
-
0
votes1
answer286
viewsA: JAVA - Database connection - Sqlexception error: Parameter index out of range
As pointed out in the comments of the question: Substitute: stmt.setString(2, autor.getNome()); stmt.setString(3, autor.getSobrenome()); For: stmt.setString(1, autor.getNome()); stmt.setString(2,…
-
2
votes1
answer2676
viewsA: Web Service Tracking Couriers
To access this service, the customer must: Request the availability of the service from the commercial area of ECT together with the safety certificate issued by responsible authority; Receive, from…
-
1
votes6
answers12886
viewsA: Doubt about logical operators && e || in Java
Complementing the answers already given, but naming the oxen, || and && are what is known as short-circuit evaluation. This means that if the first part of the expression being evaluated…
-
4
votes2
answers144
viewsA: How to implement polymorphism correctly?
I’ll stick to just one example of polymorphism: Every animal emits a sound, so any animal that considers itself an animal has to implement this method emitirSom(): interface Animal { void…
-
3
votes1
answer604
viewsA: Identify JDK version from Java
Perhaps a more efficient way is to inspect the JAVA_HOME environment variable: String javaHome = System.getenv("JAVA_HOME"); To String that returns from this method brings various information, among…
-
0
votes1
answer78
viewsA: Delete Oracle - Web Api
Your delete method has the following signature: public String deletarEvento(long codigo) He expects a codigo, which is the id that you pass to the method findById(). So, in the URL that makes the…
-
0
votes1
answer27
viewsA: Sqlite DOUBT BASIC A
Obviously your application has to be able to create and manipulate the database by itself, isn’t it? Ever wondered if your user had to go around creating databases? For example, the method below…
sqliteanswered StatelessDev 2,534 -
4
votes1
answer764
viewsA: How to create a prefix for the url using spring boot
In the application.properties file, add the following property: //Se estiver usando Spring Boot 2 server.servlet.contextPath=/app-rht //Se estiver usando Spring Boot < 2…
-
3
votes1
answer496
viewsA: How to recover an object from a Hashset
A good solution is you map the votes of Set in a HashMap, grouping by some attribute of your class Voto, in the case, the attribute voto. See the example I created below: I created a class Vote:…
javaanswered StatelessDev 2,534 -
0
votes2
answers364
viewsA: Control of Rest application transactions in spring
It can be bad from an architectural point of view and separation of responsibilities. Your controller, by definition, should not know the details of database persistence processes or act as a bridge…
-
0
votes1
answer625
viewsA: How to change from second to third screen?
What you want is this here, within the method onClick() button you will create: Intent i = new Intent(ActivityOndeVoceEsta.this, ActivityParaOndeVoceQuerIr.class); startActivity(i); Do it, even for…
-
2
votes1
answer108
viewsA: Receive a Localdatetime from an html form
To work with the new Java 8 Date API in Thymeleaf, you need two things that you can check for in your project: 1) a dependency with an extra module of Thymeleaf (Obs.: the version of this dependency…
-
1
votes3
answers103
viewsA: I’m not able to log data into the database
Your problem is possibly here: @ManyToOne @JoinColumn(nullable = false) public Pais getPais() { return pais; } The column pais_id is not referenced at any time in its mapping, so it is not mapped…
-
1
votes1
answer46
viewsA: Java Nullpointerexception error in construction
Your mistake is here: stmt = con.prepareStatement("SELECT nomemed FROM medicos WHERE crm=''"); The variable con was declared here: Connection con = null; The problem is that it was never…
-
1
votes2
answers151
viewsA: Doubt call method with If Java
Imagining your class is called PessoaJuridica and that it contains the method inserirDados(), within the else you would do so: PessoaJuridica pj = new PessoaJuridica() ; pj.inserirDados(); Is that…
javaanswered StatelessDev 2,534 -
0
votes2
answers839
viewsA: How do I get the Wi-Fi network name (SSID)?
Yes, there’s a way. You need a class called Wifiinfo Add these permissions to the manifest: <uses-permission android:name="android.permission.INTERNET"/> <uses-permission…
-
0
votes1
answer157
viewsA: could not open terminal for stdout
Apparently, this is a problem with a lib called ncurses5-compat-libs, that interferes with normal Gradle operation. Try uninstalling it and run some Gradle command again. If it doesn’t work, set the…
-
5
votes2
answers12870
viewsA: How to consume an external API in Spring Boot
You need a Spring class called Resttemplate. A very simple example of a get: RestTemplate restTemplate = new RestTemplate(); //1 String url = "http://www.algumacoisa.com.br/api"; //2…
-
3
votes4
answers5979
viewsA: Error while running spring security
It is not finding the bean to inject, possibly because it was not created anywhere. Try to create the bean at the end of the class: @Bean public AuthenticationManager customAuthenticationManager()…
-
0
votes3
answers3989
viewsA: How to Generate random numbers without repeating in Random?
A simpler solution would be to use a collection called Set. But why a set? Because the main feature of it is not accepting repeated numbers. It means that when the method nextInt() generate a number…
-
1
votes1
answer900
viewsA: Sort a chained list with Java Selection algorithm
Your method adapted to a list looks like this. Take a look at the code comments to understand the necessary changes: private static void selectionSort(List<Integer> vetor) { // o método size()…
-
2
votes1
answer199
viewsA: How to randomize the values of an object in java
You can use the method shuffle() of the Collections class. It takes a list as a parameter. Since you have an array, use the Arrays.asList() to convert the array into a list. Assuming you have an…
javaanswered StatelessDev 2,534 -
1
votes1
answer63
viewsA: Null Exception when importing the service into the Rest controller
Missing Annotation @Repository in interface.
-
0
votes1
answer535
viewsA: Grab object inside JSON string
You can use a library called Jackson, which serializes (object for json) and deserializes (json for object): Documentation by Jackson Basically, you need to: 1) Add Jackson’s jar to your project. 2)…
-
0
votes2
answers1583
viewsA: Java - Missing Artifact com.sun:tools:jar:0 (POM.xml)
Try one of these three ways: 1) In Eclipse, go to Windows -> Settings -> Java -> installed Jres -> select JDK and click Edit -> Add External Jars and add tools.jar (it’s in the folder…
-
0
votes2
answers2377
viewsA: What’s the difference in using Modelandview and Responseentity?
On the issue of usability, the ResponseEntity is widely used in service-oriented architectures (SOA), specifically in the construction of Apis REST, as a response element (sponse, hence the name)…
-
1
votes2
answers3282
viewsA: Read . txt files and put them in an Arraylist
The String class has the method split(String regex), that breaks a String into an array taking as parameter a character that repeats itself within that String. This array will then contain all the…
javaanswered StatelessDev 2,534 -
1
votes1
answer141
viewsA: How to get Printwriter to write in the file . txt determined String of a variable?
You need to close Pw, as this causes it to effectively write to the file. Note that Printwriter works with a data stream which, in turn, is written in a file. Executing the close() command indicates…
javaanswered StatelessDev 2,534 -
-1
votes1
answer217
viewsQ: How to directly type the decimals after the user type comma with Javascript?
I am developing a web site using javascript/jquery and in some fields the user type numeric values. Some of these fields, by business needs, have 9 decimal places: 0,00000000 My problem is that in a…
-
1
votes1
answer83
viewsA: Swift - How to make and run an Assynctask?
I believe you are looking for a feature called Grand Central Dispatch (GCD), which takes care of the competition on Swift. Take a look here.…
-
-1
votes1
answer1278
viewsQ: How to read multiple lines from a text file (.txt) and store them in the same variable?
Someone has an idea to help me extract the lines below and that always present themselves in this pattern? Palavra1 (é sempre igual) Linha a ser extraida, de tamanho variavel Linha a ser extraida,…
javaasked StatelessDev 2,534