Skip to content
Advertisement

The longest Substring without Repeating Characters

I’m starting out on LeetCode, and am currently working on the problem Longest Substring Without Repeating Characters. Given a string s, find the length of the longest substring without repeating characters. Input: s = “abcabcbb” Output: 3 Explanation: The answer is “abc”, with the length of 3. I feel like my approach should work, but for some reason it fails

Unable to run jar file with –enable-preview flag when using corretto 17

I am trying to run my application in an ec2 instance using the command nohup java –enable-preview my-application.jar But somehow the –enable-preview flag is ignored and i still get an error on startup telling me that i should try running it with the flag –enable-preview. I use amazon’s corretto-17 as the openJDK version. Does corretto-17 not support the –enable-preview flag?

Can I omit try-catch?

I want to fetch an HTML page and read in with BufferedReader. So I use try-with-resources to open it handles IOException this way: Is this a good pattern to catch and instantly throw? And what if I omit try at all and state that function throws IOException? If then any potentional memory leak? Much appreciate any advice! Answer A catch

How to set different version based on profile maven

I have a java project with mvn I need to have different version based on the mvn profile How do I set version.profile based on the profile ? Answer you can create profiles like below then your default profile is demo1, and version is 1.0.0 you can use variables in profile in your maven if you want to build with

How do I cast JPA criteria Expression to long java type

This code has not compile error but at run time gets this error: Cannot cast from Expression to int I tried using String: This also gets error: ERROR: For input string: “org.hibernate.query.criteria.internal.path.SingularAttributePath@2ed2d35d”; nested exception is java.lang.NumberFormatException: For input string: “org.hibernate.query.criteria.internal.path.SingularAttributePath@2ed2d35d” Answer In your first error, you are mixing LocalDateTime.now().minusDays with the Expression root.get(“person”).get(“birthDay”).as(Long.class), and it is not possible. The error

How to send JSONArray to PHP server using Volley?

I’m fairly inexperienced with Android programming and am having issues sending a JSONArray to my PHP server. I am using the following code to generate the JSONArray from my cursor: I believe I am misunderstanding how to properly send data via JsonARrayRequest. Here is the following code that I am using to send the data. Instead of sending the data,

Advertisement