I want to swap characters of string but this program returns garbage value. Can you please tell me what is wrong with my code. Answer You have to use constructor of String class. Then it will work fine.
Tag: string
Add strings to an array of strings inside for loop using java
I have a for loop and I want to add strings to a string array inside that loop. How can I achieve that? The output should look like this- Answer You can create the result array with a size that matches the registration array length, since you know you want to create one result for each registration entry. You then
How to get my scanner to recognize the words i have for it
I’m pretty new to java and coding in general and am trying to figure out how to get this game to work for a project at school. It is meant for you to type in a month and it will then ask you to choose a day, however when I input a month it always just says its an invalid
How can I convert arraylist to arraylist
My goal is to find on which specific index is String from ArrayList and add them to new ArrayList, So if house is [0] than i want to return new ArrayList with integer. At the begging I have ArrayList like this Input : And I want to get new ArrayList like this Output: Answer You can do it just by
Rearrange substrings using two criteria [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 12 months ago. Improve this question Given a String: I need to sort its substrings first by numbers (in descending order) and then by letters, so
method to find the the distance of two characters of a string apart and entering them into an array
trying to solve this question for school “Given a string s and a character c, return a new list of integers of the same length as s where for each index i its value is set the closest distance of s[i] to c. You can assume c exists in s.” for example Input s = “aabaab” c = “b” Output
Casting a long javax.servlet.jsp.jstl.sql.Result to list of Strings is very slow
The for loop at the end of this is very slow when there are 50k rows. Is there a quicker way to get a list of Strings from the rows of a javax.servlet.jsp.jstl.sql.Result? Use a different collection? Convert the Strings differently? The query is absolutely fine. I am not including here the custom objects that are used to run it.
Removing the integers in the output when inputted with a String [closed]
Closed. This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 7 months ago. Improve this question I am struggling on my code. My prof told us to make a line of code in Eclipse which, when
Java program that asks for user’s name and prints it – issue with error message
I have a program that asks for the user’s name and prints it back out. It can do that part fine, but it currently has the issue of not printing the proper error message when the user leaves the prompt empty and presses “Enter”. The code: The current output: The ideal output: What’s wrong? Answer The only thing that you
Replacing a portion of string entry
I have a list of Strings, and would want to replace a few characters of the individual string entry by new string and add to the list. For eg: I believe it can be achieved with regex, and I need some inputs here. Suggestions? Answer Use this code for your problem