Questions tagged as 'java'

1
answer

Doubt with the compareTo function

When I run the code below the compareTo returns a value less than zero. public class compare { public static void main ( String [] args ) { String str1 = "araraaaaaa"; String str2 = "asa"; int comp = str1.compareTo(st...
asked by 13.02.2015 / 03:49
3
answers

Is it safe to keep the context of an application in a Singleton?

I have the custom of keeping the context of an Android application saved within a Singleton as follows: public class Global { private static Global instance; private Context context; public Global() { } public static Glob...
asked by 05.03.2015 / 19:31
1
answer

Exception class creation and implementation

I'm having trouble implementing an Exception class. The explanation of the program is:    Vector strings must be initialized with "" instead of null. "    The capacity of the vector must be able to be changed by a method.    The class m...
asked by 30.03.2017 / 18:39
3
answers

What is the correct way to pass the paging data in the REST response?

In more robust applications where a table can have millions of records, it is important to implement paging in a REST API. I have seen in some projects two ways to return paging information (page number, page size, sort order, etc.) In the bo...
asked by 12.04.2017 / 19:31
3
answers

For what is Java byte type

For what is the byte type of java? ex: byte[] dados = ... ; What is the real use? Does anyone have an example?     
asked by 30.04.2014 / 00:47
3
answers

Catch latitude longitude Android - Location == null

I'm having trouble catching latitude and longitude on Android. Using this function, the "location" always returns "null". public void onCreate() { LocationManager locationManager = (LocationManager) getSystemService(Context.LOCATION_SERVIC...
asked by 30.01.2014 / 19:08
5
answers

How to avoid a comparison by brute force?

Possessing any class ClassA that has a value attribute and depending on the type of value I need to perform an operation differently, as I would avoid a raw comparison, as in the following example: / p> public class Leitor(...
asked by 11.02.2014 / 14:56
2
answers

Is there a way to use char in an arithmetic operation in Java?

The following code does not work, but I thought of something like this: char op = '*'; ... r = (y op x); I want to change the characters of op to do different operations, is this possible in any other way?     
asked by 30.08.2015 / 20:38
1
answer

Ensure that generic object passed as parameter is a subclass of an abstract class

First I would like to say that my question is not specifically about "verifying that a generic object passed as a parameter is a subclass of an abstract class." , but I could not choose a better title. If you find a better phrase, feel free to...
asked by 16.08.2015 / 04:54
1
answer

Convert LocalDate to LocalDateTime

I have the following attributes in my Filter class: private LocalDate periodoDe; private LocalDate periodoAte; However, the object on which the information is the attribute that will be filtered is LocalDateTime , so in my tests, I do...
asked by 19.09.2018 / 20:09