So I have a list of objects. Suppose they have 2 fields startDate, endDate(data type is timestamp). So if startDate is equal to startDate of another object then I have to choose the object with higher endDate. How can I achieve this efficiently. I can use 2 for loops but that would have a high time complexity…
Tag: java
Parsing currency exchange data from https://uzmanpara.milliyet.com.tr/doviz-kurlari/
I prepare the program and I wrote this code with helping but the first 10 times it works then it gives me NULL values, here is the code, I guess it is a connection problem but I could not solve it I use Netbeans, Do I have to change the connection properties of Netbeans or should I have to add
StackOverflowError while fetching OneToMany mapped entity in Spring Data Jpa
I have two entities that have bidirectional mapping. The entities are given below, I need to fetch all the customer entities along with its mapped accounts. My service code looks like this, But I am getting StackOverFlowError. The log is mentioned below, Can anyone help?? What am I missing here? UPDATE toStri…
What i should return if was an error creating a user
I have a method to create a user, this method check if the username exist and if the password is strong. If the creaton have an error i was returning a exception with a message, but i read this is not an exceptional situation so i don should to use an exception. what should I return to know if the
How to fix The following _CastError was thrown building: type ‘Future’ is not a subtype of type ‘List’ in type cast
I had tried to add behind the future and it doesn’t solve the problem. Moreover, there is a problem with the itemcount, so I left it with a number instead of add snapshot.data!.length() because I am not sure why there is an error with snapshot.data!.length() for itemcount. Answer Here is full working co…
Regex to consolidate multiple rules
I’m looking at optimising my string manipulation code and consolidating all of my replaceAll’s to just one pattern if possible Rules – strip all special chars except – replace space with – condense consecutive – ‘s to just one – Remove leading and trailing -R…
Returning an int array in Java
So I need a script that returns an array of a text document. The document is all numbers. Everytime I try to run it I get this message “This method must return a result of type int[]” this is under the checker part. I am trying to return it to another class so that I can use the array for
How to covert vw measurement to dp in android?
Android Studio Code Snippet I have an android device that has it’s maximum width and height specified in dp units. Max Width – 1079 dp Max Height – 399 dp I want to create a LinearLayout that has to be present vertically and horizontally centered with its height to be in wrap_content length …
Android RecyclerView content not updating after notifyItemInserted
I’ve got a RecyclerView that needs to update in real-time when content is received. It successfully shows all the content at first load. When attempting to add a new item dynamically, it makes no difference. Is there anything I’m doing wrong here? Much appreciated! MainActivity: Adapter: Standard …
Unable to insert null checks when using HAVING clause while building Spring Data JPA Specifications
My code is currently working using the query below and I am converting the query to JPA Specification. This is what I have done so far which is working but in an unclean manner. How do I improve this code so in the future it can accept more criteria without going through so many null checks like this? Thanks!…