Skip to content

Tag: java

How to count count the number of names Java

Hi guys. I’m new to Java, currently learning Strings. I have a task to count the number of names, the length of the name must be at least two, the first letter of the name should start with upper case, the second with lower case. The issue is that I don’t know how to use the Character.isUpperCase(…

Read Large file in Chunks and Compare each line in Java

I have a text file with entries like below. I want to read the file as input and compare the time consumed by each event using Java. Like event1 has taken (11025373 – 11025373) = 4ms time. (start – end) event2 has taken (11025397 – 11025387) = 10ms time. I initially thought to read line by l…

Why cant I initialize the Webview

im just starting out with android studio, i have imported WebKit but those imports are grayed. and i cant initialize the webview “private WebView webview” shows errors how to do it correctly? Answer I was using kotlin instead of java that was the issue (beginner mistake lol) my issue was that i co…

JPA Specification for Enum

My JPA Entity as an Enum field Where If I add a where condition with a specification what is the correct way to include Enums into Specification queries? Answer Try doing this:

Find the first Recurring letter in Java

I wrote the code as follows but it doesn’t return the first recurring letter properly. Example: In the word “statistics” the recurring letters are s, t, and i. But the letter t recurs sooner than the letter s and i, but my program returns s instead of t. What do I need to do for it to return…

Intersections of given sets with repeat of elements

Logic to count intersections in a given set is correct for no repetitive pattern, but for this set, the output count is wrong. Code output is 8 Expected output to be 3 Answer Try the following code. I use Math.min() for the second statement of for-loop to avoid IndexOutOfBounds error Output is 3