Skip to content
Advertisement

Tag: string

How to find the longest string object in an arrayList

Here is is my problem, I have to explain a lot, because it’s a quite complicated. I have created an arrayList<Word>, that contains strings as objects. In my case, I have three classes, all working together, that is supposed to represent a dictionary. The first class is called “Word”, it has a constructor, and has simple methodes like .length, adds

Java text wrap issue, caused by input width

I am trying to wrap text based on a width of 10 characters. After looking at other questions, I have the following: This works until a word in my string is longer than the specified width. When this occurs, the rest of the string is printed on line line instead of still following the line width rule. Any ideas? I

Replace Unicode escapes with the corresponding character

I’m trying to convert code points, such as u00FC, to the character it represents. An example to explain what I mean: First Console line: Input: Hallu00F6 Second Console line: And Now: Hallö EDIT: Because sometimes it didn’t work with multiple Unicodes in The Trombone Willy’s answer, here is the Code fixed: Answer Joao’s answer is probably the simplest, but this

How can i put a string in one line

i’m doing some conversion, from Hex to Ascii, when i convert the string, i got the following example: F23C040100C1 100D200000000000 0000 I know that the string is coming like this, because of the base 16, but i want too put it in just one line, like this: F23C040100C1100D2000000000000000 How can i do that? I have tried: Answer There are multiple

Unique regex for first name and last name

I have a single input where users should enter name and surname. The problem is i need to use checking regEx. There’s a list of a requirements: The name should start from Capital Letter (not space) There can’t be space stacks It’s obligate to support these Name and Surname (all people are able to write theirs first/name). Example: And the

Java .split(“|”) not working

I just ran into the problem that the split method for strings wouldn’t work with character “|” as an argument. It somehow separates each character in the string. Code: Output: Answer Use escape character before | like below: Similar “escape character logic” is required, when you are dealing/splitting with any of the below special characters (used by Regular Expression): OR

How many objects are created in StringBuilder?

Based on my understanding on String objects, that every string literal is being added/created on the String Constant Pool. two objects are being created, one is the “hello world” being added on the constant pool and the other object is the new instance of String. Does the same principle is being applied when it comes to StringBuilder? in the StringBuilder

Advertisement