Apparently, this code works for the solution, I’m just having a hard time understanding the question. For this line: sum is an integer, a.charAt(len1) returns a char, how can it perform addition between an integer and a char? also, what does it mean to – ‘0’? Answer chars are essentially smaller ints with fancy printing associated to them. A char
Tag: string
Sort List of Strings arrays in Java
I’m trying to make a program that consists of an array of Strings . now I need to sort them in order ‘PJ’, ‘GHS’, ‘FJ’, ‘PAS’ and date. input : output: //Always ‘PJ’, ‘GHS’, ‘FJ’ then ‘PAS’ Answer You should consider using custom java classes instead of String Array. Find below an example to do it .
How do I split the plus minus number string in java? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question Input : String arrr[] = new String[4]; arrr[0] = +2501 +2502 +2503 +2504 arrr[1] = -2501 -2504 +2505 +2506 +2507 +2509 arrr[2] = +2501 +2511
How can i remove different strings from one string?
I’ve been searching for a while but other answers are quiet different to what im trying to do. I’m trying to delete prepositions from a string but i wonder if there is any way to delete them without doing it one by one like i’m doing right now: (I’m trying to delete spanish prepositions like (de, del, el, la)) Once
Best instructions for null scenario in String approach [closed]
Closed. This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 2 years ago. Improve this question I want to hear opinions and arguments on this topic, I’m pretty undecided. The equals method is the best one for
How to append in String Builder in java? [closed]
Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this question? Add details and clarify the problem by editing this post. Closed 2 years ago. Improve this question Suppose I have sentence in String X. How can I split each word in sentence and add a span tag for each word with class
How to implement Body Mass Index (BMI)in Java
My problem is how can I implement without the Scanner method and with Math.round and Math.pow? Here is my code: My another idea was It is only for a certain value. In my case with a weight of 75.0 and size 178.0 Answer It’s up to developer to choose how to initialize parameters. If don’t want to use scanner the
How to replace even values in string with ASCII value?
Suppose I have a string as ABCDEFG. I want to replace the even values of this string with their ASCII value. How should I do? Answer You are almost there, you simply need to build the resulting string. Strings are immutable, so replacing would create a new String each time. I would suggest a StringBuilder for this task, but you
How can I split a string without knowing the split characters a-priori?
For my project I have to read various input graphs. Unfortunately, the input edges have not the same format. Some of them are comma-separated, others are tab-separated, etc. For example: File 1: File 2 Rather than handling each case separately, I would like to automatically detect the split characters. Currently I have developed the following solution: Basically I pick the
How do I remove a word that contains a dash from a text?
so I want to remove a word that contains a dash between them like off-campus alongside other things that I want to remove. here is my code so far. so far it prints CS is a wonderful class So WONDERFUL amazing class cleaver class must-remove Answer You could use the regex w+-w+, which means 2 words w+, separated by a