Skip to main content
Filter by
Sorted by
Tagged with
0 votes
0 answers
43 views

ClassCastException is not coming in JDK21 in Eclipse I check whether I get a ClassCastException in the console by using the TreeSet<StringBuffer>. However, the values are sorted and the output ...
soundarya damotharan's user avatar
0 votes
1 answer
64 views

I'm getting a stream of words from server. The objective is to combine the words into a single sentence dynamically. Now what happens is as follows, the values are appended, but the entire string is ...
Febin Johnson's user avatar
0 votes
0 answers
103 views

I implemented the following multiple producer multiple consumer lock-free queue, however it crashes when I run it, inside dequeue function with "std::bad_alloc" exception. I don't understand ...
Andrey Rubliov's user avatar
0 votes
3 answers
147 views

I'm in college and our professor gave us this exercise where the user should input a sentence such as "Life is great" (positiveInput in this case) and we should replace the word "is&...
anothercodingnoob's user avatar
0 votes
2 answers
129 views

I am trying to create a csv file with the headers coming from a map and the values coming from an object. I have a Java object which stores different attribute data. public class MyObject { ...
Mohit224's user avatar
  • 493
0 votes
0 answers
30 views

Given #include<string> #include<stringstream> #include <fstream> int main(int argc, char* args[]) { std::fstream file("MyFile.txt", std::fstream::in); std::stringbuf ...
Raffaello's user avatar
  • 1,705
0 votes
3 answers
37 views

I have this method and I want to know is there a practical and clean way to write this code shorter: This excersice was from a Dart Apprentice: Beyond the Basics book. void main() { final lyric = '[...
zex_rectooor's user avatar
  • 1,040
0 votes
1 answer
56 views

Hi i have this block of code for a ring buffer library ieee; use ieee.std_logic_1164.all; entity ring_buffer is generic ( RAM_WIDTH : natural; RAM_DEPTH : natural ); port ( clk : ...
Majora-NK's user avatar
1 vote
1 answer
93 views

I am using ThreadLocal StringBuffer for storing entire log to move it to kibana at the end of each test case execution. But when I am running cases in parallel, the log is loosing some entries. I am ...
Siva Sai Phalguna Kaipa's user avatar
-2 votes
1 answer
135 views

Hello I am writing a program that write and read file XML in Java. Here is the Writing file public static void main(String[] args) throws IOException { File file = new File("C:\\Test\\...
Tuan Do's user avatar
  • 11
-2 votes
4 answers
144 views

As the title says. In want to remove the last letter of every word in an array and put it to the beginning of every word. Here's an example (Input): Hello I am a player And here's the output: oHell I ...
Julian's user avatar
  • 1
-2 votes
3 answers
316 views

I just started learning Java and I'm doing a little program to convert a decimal number into binary numbers using only while loops. The results were reversed, therefore I'm using a method to reverse ...
Chris Chen's user avatar
0 votes
0 answers
399 views

It is preferred to use char[] to store passwords rather than a String in Java. But can we use StringBuffer instead of char[] to store passwords?
Aman Kumar's user avatar
0 votes
1 answer
219 views

I'm trying to pass a XML object through a StringBuilder to compare to Objects, fitting to my needs. I was wondering if there is a nice way to remove specific tags from the whole String. Underneath I ...
Bltzz's user avatar
  • 13
0 votes
1 answer
62 views

The code should do a reverse and output the result to out.txt, but this does not happen, can you explain my mistake in the code. Thanks in advance import java.io.BufferedReader; import java.io....
Khirokhito's user avatar
0 votes
2 answers
657 views

TLDR: I am looking for a datastructure with the properties of a string buffer that I can access by index in dart. Long version: I need the properties of Stringbuffer (very efficient at adding ...
paul maier's user avatar
1 vote
2 answers
457 views

After reading text file that contain words and numbers, I split it into words and numbers and left with blank lines in both splited words and numbers. I try to remove the blank lines but the code did'...
Najibu Tanimu's user avatar
-1 votes
2 answers
106 views

set.add(new String(s) + (ch == 0 ? "" : ch) + new StringBuffer(new String(s)).reverse()); I encountered this code from written by someone. It is java code. s is a char[]. set is a String ...
wangge's user avatar
  • 145
-2 votes
1 answer
344 views

I'm trying to make a If else condition to check if a current data exists on the database using a JSON request on a java application consuming a Rest Webservice. So, I want to receive a boolean or make ...
Luís Ambrozin's user avatar
-1 votes
4 answers
1k views

My code is as below. i need to add single quotes for each word in string with single quotes after appending DD to it. public class Main { public static void main(String[] args) { String ...
Pratyusha Karra's user avatar
-1 votes
3 answers
220 views

I have a very basic question. I have read that if we have a multi-threaded application then it is better to go with StringBuffer. But if we have a single thread application then it’s better to go with ...
the_novice's user avatar
-1 votes
1 answer
115 views

I have little problem with my code, I split in Java String to table, then for I pick selected char and replace it with StringBuffer method. The problem is when I use sout method at the end with ...
tomeklfc's user avatar
1 vote
0 answers
110 views

1. Summarize the problem I've heard String + operation will be changed when compiling after JDK 1.5. But sadly I couldn't find the optimization case. What did I miss? What did I do wrong? 2. Describe ...
creep's user avatar
  • 19
-2 votes
1 answer
378 views

I am able to reverse a string. For example, I can reverse "reverse a string" to "esrever a gnirts". I am trying to create a function that reverse a word from a sentence. I only ...
Chaitanya Maligi's user avatar
1 vote
1 answer
54 views

What will happen when we compare String and Stringbuffer with the method equals? String s1= "121"; System.out.println(); StringBuffer sb = new StringBuffer(s1); sb.reverse(); System.out....
MANAS2021's user avatar
1 vote
0 answers
55 views

@Override public StringBuffer insert(int dstOffset, CharSequence s) { // Note, synchronization achieved via invocations of other StringBuffer methods // after narrowing of s to specific type // ...
joshua's user avatar
  • 11
0 votes
2 answers
156 views

If I had an array that had store these data String stringArray[] = { "Apple a Day Keep You Away", "Banana a Day Keep Her Away", "Cat like Dog"}; ...
NewbieCoder's user avatar
1 vote
1 answer
4k views

What would be the kotlin way to handle multiple string concatenation? --edit-- placing the piece of code that led me to this doubt fun getNCharsFromRange(n: Int, range: CharRange): String { val ...
Mauricio Rodriguez's user avatar
0 votes
5 answers
979 views

String s1="Hello"; s1=s1.concat("World"); String s2="HelloWorld"; System.out.println(s1); System.out.println(s2); System.out.println(s2==s1); //false As after ...
Dekay's user avatar
  • 31
0 votes
4 answers
8k views

I'm writing a program with a text file in java, what I need to do is to modify the specific string in the file. For example, the file has a line(the file contains many lines)like "username,...
Alan K's user avatar
  • 197
0 votes
2 answers
529 views

How can I use a method like this private boolean respectPattern(String password) { Pattern passwordPattern = Pattern.compile( "^(?=.*[a-z])(?=.*[A-Z])(?=.*\\d)(?=.*[.@$!%*?&])[A-Za-z\\d@...
Ob-la-di's user avatar
  • 253
0 votes
1 answer
596 views

I have a String value which has a maximum length of 629 characters. i am using StringBuffer to insert values on specific offset index. StringBuffer sb = new StringBuffer(" ...
KeanHo Leong's user avatar
0 votes
1 answer
114 views

public static void startGame(){ //int stone = 0, diamond = 0, iron = 0, gold = 0; StringBuffer blockys = new StringBuffer("\uD83E\uDDCD ▯▯▯▯▯▯▯▯▯"); Scanner input = new Scanner(...
user avatar
0 votes
0 answers
342 views

I am trying to make a program that will choose a random assortment of 9 letters where the user specifies how many each of consonants and vowels to select. So far I have: char consonants [] = {'b','c'...
CossyBear's user avatar
0 votes
3 answers
299 views

Why printing the array items in a loop taking more time as compared to appending all array items into StringBuffer and then print? In this, I printed array items in the loop. public static void main ...
SOURABH GUPTA's user avatar
0 votes
0 answers
1k views

I have this existing API running in loop which creates a connection and fetches huge json(1 GB) in each iteration from a service through restTemplate as follow: ResponseEntity<String> response =...
Gautam Tadigoppula's user avatar
2 votes
2 answers
643 views

Why is StringBuffer needed in java? i am totally new to java, and was studying about operations on Strings and String methods when i saw another set of methods, which were similar somewhat similar, in ...
Siddhant's user avatar
  • 644
-1 votes
4 answers
1k views

I have a function and Technical Leader review code and said : Why this if statement? It's basically the same message. If you want customized, use a string builder with the type. How to change it , can ...
khoale's user avatar
  • 15
1 vote
3 answers
1k views

I was expecting the ClassCastException when trying to run the following piece of code: // TreeSet<StringBuffer> t = new TreeSet<StringBuffer>((a, b) -> - // a.toString().compareTo(...
Rahul Sharma's user avatar
1 vote
1 answer
216 views

Consider the following String: String str = "XFB_PART~\XFB_IDF~\XFB_MODE~0\XFB_LOCALITEM~\XFB_REMOTEITEM~\XFB_MSG~tool\ soundgarden~\ASYNCHRONOUS~0\BROADCAST~0\XFB_LOCALAGT~" What I would like to do ...
Jesse James's user avatar
  • 1,243
1 vote
2 answers
332 views

I got into this situation to write a generic function which can extract only first occurrence of the character and all the number from a string. Input String (Say): ABC123-45DEF-GH67IJ9 Output String:...
Abhishek's user avatar
0 votes
2 answers
92 views

StringBuffer sb1 = new StringBuffer("abc"); StringBuffer sb2 = new StringBuffer(sb1); sb1.append("d"); System.out.println(sb2); Since StringBuffer is mutable and sb2 points to sb1, i ...
prabhakar Reddy G's user avatar
0 votes
2 answers
289 views

I have appended some strBuild with some characters and putting that strBuild into stringBuildArr. then called the java.lang.StringBuilder.delete(int start, int end) function on strBuild. Here is the ...
vaibhavcool20's user avatar
0 votes
0 answers
805 views

I'm trying to make getArrayStringLongerThan() constructor that returns a StringBuffer array with COPIES of StringBuffer objects in the array parameter that have a length greater than the length ...
Ali's user avatar
  • 1
0 votes
2 answers
399 views

I have a String(txt) and in this String is html code. I will search the String with txt.indexOf for ("< ac:structured-macro ac:macro-id=") and delet it with StringBuffer(sb) sb.delete(Index, ...
Lorenz's user avatar
  • 51
-1 votes
1 answer
165 views

I'm trying to check the with an if-statement if two strings are the same(which they are), but it doesn't work. Here is my code and my first input value (https://i.sstatic.net/hEkr7.jpg) . In the ...
getNordic's user avatar
3 votes
2 answers
575 views

I am studying String in java and while studying I came to know that hash code is generated for every string. I want to know how hash code is generated in the case of StringBuffer.
Jasmeet Singh's user avatar
0 votes
2 answers
2k views

I use Android Studio.I have a text file with some of numbers and I want to calculate them with others numbers. When I am try to convert them from string with method Integer.parseInt on program start I ...
Rusla's user avatar
  • 1
0 votes
1 answer
129 views

I need to compose a long string (4324 characters) and want to use StringBuffer for this purpose. Most of the string will be whitespace but some portions contain orderdetails. They must appear at ...
kometen's user avatar
  • 8,238
0 votes
1 answer
271 views

methods ‘contains’ not defined in class ‘stringbuffer’ compilation error is being generated from the following code: import 'dart:math'; var now = new DateTime.now(); Random rnd = new Random(); ...
albert.appinventor's user avatar

1
2 3 4 5
10