Questions tagged as 'java'

2
answers

How to count the amount of occurrence of a substring within a string?

I have the following return:    EXCEPTION, ClassException, EXCEPTION, Exception Message I'd like to get the number of times the String EXCEPTION appears using Regex . I used the following code: Pattern.compile("(EXCEPTION)",Pa...
asked by 16.01.2014 / 13:47
3
answers

Prevent an action from being intercepted by the Interceptor Handle

I implemented a class to intercept some urls and check if I have a logged-in user, if there is access to the url, otherwise I am automatically "played" to the login screen. It happens that in the page of a login I have a link to register a us...
asked by 23.11.2014 / 03:48
1
answer

Good practices (Refactoring) - best way to treat one method with for inside another

Personal using good practice in Java how should I convert this method? Should I break in several methods and within each of them do the? public void salvarObjetos(Objeto objeto){ for(Objeto1 obj : container.getList()){ . ....
asked by 14.05.2015 / 16:51
2
answers

Why is it not possible to modify local variables when accessed within anonymous classes?

When trying to access a local variable from a method of an anonymous class in java, we usually get a syntax error if we try to modify its content. Some IDE's suggest that we transform the variable into final , so that its content becomes i...
asked by 23.03.2017 / 14:56
1
answer

What is the difference between sendRedirect and requestDispatcher.forward?

What is the fundamental difference between using methods response.sendRedirect("Alguma pagina"); and RequestDispatcher despachar = request.getRequestDispatcher("/Alguma pagina"); despachar.forward(request, response); Since "they do p...
asked by 02.10.2015 / 20:52
3
answers

Why am I 'calling' the subclass method?

public class A { public String imprimir() { return "A"; } } public class B extends A { public String imprimir() { return "B"; } } public class C extends B { public String imprimir() { return "C"; } }...
asked by 05.09.2018 / 20:39
2
answers

Spring Security with Java EE

Hello, I'm developing a Maven Enterprise Application EAR project and I'm currently implementing the authorization part using Spring Security with Annotation instead of xml. Project Structure: FileAppConfig.javapackagebr.com.seguranca.confi...
asked by 11.05.2015 / 16:21
1
answer

What are the differences between TreeSet, HashSet and LinkedHashSet?

The idea of Set is not to allow repeated elements, in Java there are three implementations TreeSet , HashSet and LinkedHashSet found some differences In this answer , I would like to know in detail if there are others and in...
asked by 15.06.2018 / 17:12
3
answers

What best practices when implementing requisitions?

When implementing calls to a webservice I have worked with the following schema: implement a class that extends AsynkTask and within method doInBackground() I make the call to my service. One particularity here is that instead of...
asked by 22.08.2015 / 03:57
2
answers

What are the for loop syntaxes in java?

Hello Everyone programming in Java should already be tired of using for looping, which almost always has a syntax similar to this: for (int x = 0; x < y; x++) { ... } I was analyzing some codes and came across a different s...
asked by 31.03.2014 / 04:42