Java thread, because its "connection error when i try to post in dpt"

I wanted to remove punctuation from string in Java. I thought StringBuilder is for string manipulations?

public class Excercise {
public static boolean isMultiple(long a, long b) {
if (a%b==0)
return true;
else
return false;
}
public static StringBuilder noPunctuation(StringBuilder s) {
for (int i=0;i

Attached: quest content is geeky now.png (394x553, 49K)

Other urls found in this thread:

docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html#deleteCharAt(int)
twitter.com/SFWRedditVideos

do s.charAt(i)

>Java

How about not modifyng the very string you're iterating over while you're doing it, consider making a second string builder to save the trimmed text to and then return that, it's gonna have a problem with it otherwise once you fix your s[i] syntax

Thank you! there are 2 errors left. One with
Excercise.java:27: error: incompatible types: String cannot be converted to StringBuilder
noPunctuation("Let's try, Mike!");
and another with s[i].remove(). I also tried s.remove(s.charAt(i)) but its not working

"Let's try, Mike!" is not a string builder, try saying this instead:

new StringBuilder("Let's try, Mike!")

"Let's Try Mike" is a string and not a StringBuilder. Try this maybe?

noPunctuation(StringBuilder("Let's try, Mike!"));

Forgot the "new" keyword (I use Kotlin lol). Follow this guy:

In Java, unlike JavaScript (which has absolutely no correlation other than Java in the name), array and collection accessors aren't interoperable. You can't a[i] with a Collection and you can't a.get(i) with an array. That said, the StringBuilder.remove(int index) method must be called via the StringBuilder object, and not one of its characters, and takes in the character index, instead of the actual character.

The other error is because String != StringBuilder and there's no auto cast between them. You must use 'new StringBuilder("String")', although afterwards, if this StringBuilder is used in place of a String, Java calls StringBuilder.toString() automatically.

>You can't a[i] with a Collection
Why Java still doesn't allow operator overloading?
Is there a real reason for this?

Because C# exists

whats a collection?

>what is regex

Any class that implements the Collection interface. Things like ArrayLists, essentially common data structure classes.

They wanted to simplify the massive palette of C++ features that constantly fucked over developers eg: one developer on a team completely redefining what operator+ does in a nonintuitive manner that makes their teams library practically unusable except to the single developer that wrote it.

It can get way out of hand. If it's an option allowed by the language, the human will fuck with it.

is this the guy who turned into a tranny? w-well this is me?

Attached: file.png (157x228, 33K)

No, it's her twin brother.
I Wish I was joking.

can't he just iterate over the string backwards? i'm assuming you're warning him against it because skips may occur

So it is a language designed around exceptionally retarded users?

>her

i think he may be gay too

Attached: questionable content white guy.png (800x1160, 180K)

>That image
Leave it to a woman to fuck up a program that badly

yes

Read the fucking manual.
docs.oracle.com/javase/7/docs/api/java/lang/StringBuilder.html#deleteCharAt(int)
It takes the index.

This guy really likes sòy

public static String noPunctuation(String s) {
return s.replaceAll("[\\.\\?!,]", "");
}

Imagine the self hating cuck cretin behind these comics. What an existence that must be

>posting this unfunny s,oy humor trash
ebin post fren xD 999 redd1t gold 4 u xD
kys

> Raisins are rich people food

What in the hell...does no one point out how ridiculous this stuff is?

The only person 'displaying their middle class ass' or whatever is whoever wrote this thinking poor people don't eat freaking raisins.

stringbuilder is pretty much automagically optimized for you. literally can't think of any valid reason to really use it.

what I mean by this is when you do shit to strings where a stringbuilder can be dropped in instead, the compiler literally replaces it with StringBuilder code.