Questions tagged as 'java'

2
answers

What is the purpose of the setTag and getTag methods in View?

In% with% declared in this way below, the TextView is used as the definition of the 1 attribute. See: <TextView android:id="@+id/tvJonSnow" android:layout_width="wrap_content" android:layout_height="wrap_content"...
asked by 27.06.2017 / 16:52
2
answers

CORS JAVA (ERROR)

I'm trying to connect to an API that was made in Java, but I always get the error when trying to connect (I want to feed a mobile application, done in JS / Cordova). When I connect (via Browser) I get it, the API returns and everything works...
asked by 06.06.2017 / 20:56
3
answers

How do I use replace () for the last occurrence?

The String#replaceFirst() method is used to replace the first occurrence of a substring in a string , but how should I proceed if I want to do this with the last occurrence? The question is how do I make the condition to parse the...
asked by 08.03.2015 / 16:43
2
answers

Generic, extend to an X or Y

How do I make my generic class only receive types that extend from class X or Y? Example: class MinhaClasseGenerica<T extends ClasseX ou ClasseY> Sorry if it got a bit confusing, I'm a newbie yet, I can not explain very well.     
asked by 18.04.2015 / 00:26
3
answers

Extract date with Regex

I'm trying to extract a date from a String, but I'm not getting it. Example: String stringQualquer = "um teste qualquer12/02/1998 19/09/1880 Nulo"; I want to get the first date of this example "12/02/1998". I tried that, but it did no...
asked by 02.08.2018 / 21:35
4
answers

Assigning Arrays in Java

I own two String Arrays and I have to compare them. After the comparison I must assign the repeated values in another Array. My problem is that I want to assign just the repeated Strings without the Strings that do not repeat. Code: //A...
asked by 16.07.2017 / 19:56
1
answer

How to set contents in position 0 with field disabled?

I need, when my component receives a text (it will receive through a query), the text is "set" at the beginning of the field, because in many cases the text is long and the beginning is omitted. The detail that is complicating the solution is th...
asked by 25.08.2017 / 18:07
1
answer

Add 1 minute to hour

I have a problem solving an exercise. It may be easy but I can not seem to find the right solution. I have the following class Time public final class Time { private final int hours; private final int minutes; publ...
asked by 06.07.2018 / 00:34
2
answers

How to make a ScheduledExecutorService launch a new task while the previous one is not yet finished?

I'm implementing a scheduler to run some threads on my system at x time intervals. The big problem is that if thread 1 still has not finished running, a 2 does not start, even its time having arrived. In the example below I "forced" this erro...
asked by 05.07.2018 / 21:34
2
answers

How to filter a HashMap returning another HashMap using Java 8 lambda?

The following code runs through Set and filters only objects that isActive() is true . public Set<InvoiceLineDocument> getActiveLines() { Set<InvoiceLineDocument> activeLines = new HashSet<>();...
asked by 15.05.2018 / 20:15