Find all strings with smallest length in an array

I want to return the smallest values from my words array Finding the shortest word is easy but I am not sure how to return a new array with the shortest words. public class Test{ public static …

Merge lines that share a word-link

so I’m having a small problem in java. I have something like “Victor Fleming” “Gone With” “With The” “The Wind.” So what the sentence should actually look …

How to solve Cannot invoke “String.compareTo(String)” because “[]” is null?

import java.util.Scanner; public class Search { static Scanner scanner = new Scanner(System.in); static Scanner kb = new Scanner(System.in); static Scanner kb2 = new Scanner(System.in); …

Index of first distinct character between two strings using a recursive method

I need to find the index of the first distinct character between two strings using a recursive method. Examples with expected outputs: rFirstDistinctPlace(“Little parcels”, “Little …

How to check if a JWT Token has expired without throw exceptions?

I’m developing a Java application (using Spring Boot) and I need some help: This application receives as input a JWT token which I process in a method. The method for now is the following: private …

Javers – comparison String, Collection and Boolean with defined rules

I have 2 classes: @Data @Builder public class Boss { private String name; private List subordinates; } @Data @Builder public class Employee { private String …

How to replace occurance of numbers with single value?

I have below code String str = “/admin/3138/misc”; boolean isNumbers = str.chars().anyMatch(Character::isDigit); System.out.println(isNumbers); if (isNumbers) { str = str.replaceAll(&…

Representation of an array as a polynomial

What this method should do is take an array of doubles and convert them into a polynomial, for example, if the array is given was [2.0, 3.0, -2.0] the method’s output would be 2.0x^2 + 3.0x^1 – 2.0. …

I want to remove space happend after removing substring [closed]

public class RemoveString { public String removingOccurences(String input1, String input2) { String newString = input1.replaceAll(input2, ” “); return newString; } …

Recursively getting string user input with Scanner class in java

So, I want to receive input from the user, check if they used alphabetical values and then check if it is too long. If too long, I want to start again from the top (checking if alphabetical) by …