Skip to content
Advertisement

Tag: string

How to randomize ArrayList without using Collections.swap()?

I was asked to create a method that randomly rearranges my list which contains arrays. The list contains multiple persons and their names and surnames. My question is how do I move a person (array containing two elements name and surname inside the list) to a different index without using the method swap()? Because our list does not support that

Get error when trying to split file path in Java

For the above code, I get the following output where p is a Path object. C:repoUnit-test-coverageabcdunit-test-repopcmbbsourcepcmbbdatabaseWorkOrderTenderUtil.plsql I want to get the file name without extension. So I tried the below code. Then I got the following output. WorkOrderTenderUtil.plsql To get the filename without extension what I tried to split the above output by .. But splitting is not happening as

Splitting string doesn’t give expected output

I want to split a given string according to the given format -> ,;:.?! .What I am doing is given below, but whenever it is encountering more than 1 space it is adding space to the array. I just want the word not the space. INPUT:: hello Hello HEllo hi hi: hi! Welcome, welcome OUTPUT:: 13 hello Hello HEllo hi

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. The expected output is something like shorestWords [] = {“is”, “is”} Answer Since most of the answers are not considering that result is expected in String[] instead of

Advertisement