Skip to main content

All Questions

Tagged with
1 vote
2 answers
290 views

Optimize printing massive strings to System.out with respect to time

I need to cut the time it takes to print a large string by ~50%. I went from using s1 + s2 to using StringBuilder, and instead ...
abc556's user avatar
  • 11
0 votes
1 answer
692 views

Java exercise: String processing and type conversion

The exercise is from a Java-course in which I'm enrolled. The classes Book and APIResponseParser were provided by the instructor. For Book I had to add just a few getter- and setter-methods. For ...
michael.zech's user avatar
  • 4,814
0 votes
2 answers
2k views

Data structure to count occurrences of words

I have some code for a assignment where the main marks are awarded based on efficiency. The program uses a given wordgenerator which generates random words and adds them to a user-made data structure. ...
Andy Orchard's user avatar
2 votes
1 answer
4k views

Case-insensitive replacement of "java" with "JAVA" using String.substring()

Assignment: Create a program Substitute that gets a sentence from the user and replaces every occurrence of the word java (uppercase, lowercase, or a combination) with JAVA. You may not change the ...
Eric Wessel's user avatar
1 vote
1 answer
1k views

Find all occurrences of the word "the" without using regex

I have an assignment to find all occurrences of the word "the" without using regex: Use the indexOf method to do this. The word "the" could also appear in a ...
Eric Wessel's user avatar
1 vote
4 answers
97 views

Form a [email protected] address, eliminating diacritics from a name

I'm an amateur programmer who just started learning programming, my school gave me an assignment to create code that reads a surname and lastname from an input dialog box and then to edit those name ...
Semi Turdean Rajhi's user avatar
-2 votes
2 answers
673 views

Manipulating strings and character positions

Write a program that manipulates two strings. The program inputs two strings (string1 and string2) and a character (...
Sam Leavitt's user avatar
5 votes
4 answers
16k views

Word Guessing Game

I'm trying to learn Java (albeit rather slowly). I'm in a computer science class at my highschool and I've written this little bit of code for a project. Basically it is a word guessing game where if ...
user avatar
4 votes
3 answers
2k views

Sorting strings in a one dimensional array

What are the better solutions possible? I have a character array with different strings. There is a max size for the strings. In case a string is smaller than max size remaining places are filled ...
varsh's user avatar
  • 41
11 votes
8 answers
18k views

Return a string without the first two characters

I'm new to Java and am trying to solve a scenario. Even though I've succeeded and it works, I've just wondered if there was a more practical way of doing this task. Is there a quicker or more ...
3lliot's user avatar
  • 412
0 votes
1 answer
121 views

Processing a string from the console

How can I make this program run faster? On enter, I have a string from the console. For example: 1 1 7 3 2 0 0 4 5 5 6 2 1 On exit, it will be ...
Alex's user avatar
  • 11
2 votes
1 answer
218 views

High School Java Class: Pong Project External Reviewer

It would be a huge help if you could tell me ways to make my code run smoother and if I could add more code to my program to make my program more unique. Panelball class: ...
user2260077's user avatar
8 votes
3 answers
20k views

Replace multiple occurrences of a character

I try to replace multiple occurrences of a character with a single character. Input: hhiii!!! hooowww aaareee yyyooou??? Output: hi! how are you? ...
Mohammad Faisal's user avatar