I FUCKING HATE JAVA REEEEEEEE

WTF IS WRONG WITH MY CODE AAAAAAGGGGGGGGHHJRRREE

Attached: x1uxpll8jeo11.jpg (3264x2448, 1.07M)

What are you a fucking retard? It's telling you exactly what the problem is christ

How could someone be this dumb?

Attached: duke.jpg (891x888, 95K)

If you can't use Java just give up

WHERE IS LINE 203 aaaaaaggrrr REEEEEEEEE

Attached: db4.jpg (495x362, 35K)

if (numReps != 0)
{
// Do stuff
}
else
{
return();
}


Not doing:
if (numReps == 0) {
return;
}

// Do stuff


Never going to make it

Attached: smuggy.jpg (378x485, 40K)

are you trying to write some elegant recursive method but failing horribly?

Attached: 1537840291225.png (573x551, 440K)

Attached: 1479856923909.jpg (292x479, 34K)

Not the answers but something to improve the general idea. 1) initialize combined to "" 2) do that if (it's useless) 3) drop parenthesis around return statement (why did you put 'em there? Return is a statement, not a function) 4) (optional) use a string builder instead, for max performance (tm)

No. user is literally just concatenating a string n times lol

public string repeatString(string s, int n){
int x = 0;
string s2 = "";
while(x < n){
s2 = s2 + s;
x++;
}
return s2;
}


There you go OP lucky I'm very boree

I mean "2) drop that if)

>not knowing how compilers work

I learned super beginner stuff from CodeHS. The start of my programming career yes indeed lmao.

Why are you putting parenthesis around the return value?
Why are you using them when there is no return value?
Why do you expect us to do your homework for you?

Attached: code.png (3000x3000, 274K)

The actual error is at line 15. That error causes a cascade of compilation errors, which is why all those other lines are mentioned.

replace
return ();

by
return text;

as if numReps == 0 you may want to return the initial string without changes.
You should test if text is null but it might be too soon for you to learn about exceptions.

I seriously can't tell what you're trying to do. Are you trying to repeat a string n times, or are you trying to make a string of n repetitions of text?

Either way, you failed at both obviously

The only redeeming quality that Java has is that somehow Notch used it to make Minecraft. Even then, its c++ rewrite is way faster.

java is great. blame OP
and dont call me poo in loo

Attached: 1527782967604.jpg (612x612, 36K)

Because java is *clearly* the issue here (and I'm not implying that it isn't shit)
What's up with the board lately? I assumed it'll go back to normal once the summer is over. Is this because of the master/slave and Linux coc drama?

poo

here you go rajeesh

public String repeatString(String input, int repetitions)
{
if(input.isEmpty() || repetitions < 1)
{
System.out.println("you can't do that, dummy!");
return "";
}

String combined = input;

for(int i=0; (repetitions-1)>i; i++)
combined = combined + input;

return combined;
}


protip, you can't return (). that doesn't mean anything. because you declared a public String, it needs to be a String, so you would return "()", or an actual empty string, ""

I will proceed to send you the costs of my ribcage operation, my sides exploded.

Stop helping retards like this. I want to keep my 300k TC.

don't listen to them. Everyone starts from nothing, and everyone is always learning.

Sure, but look at his attitude. Instead of trying to learn what he's doing wrong he's blaming the language.

Is Java too hard for you? maybe you should consider a career change while you still can.

Let's add this to the cringe collection (I'm no good at art)

Attached: embarass 01.jpg (1050x1050, 114K)

This doesn't work unless you include the compiler errors.

Use .png unless you want to be in a private cringe collection yourself.

The problem is "return ()"
A set of blank parenthesis is only allowed as a zero arg method call, zero arg method declaration, or zero-arg lambda. Since it's saying "-> expected", that means it's interpreting it as the last.

Also this code is fucking horrible. Use a StringBuilder if you're doing to concatenate in loops so it doesn't have to allocate a new String object (plus the underlying array) for every iteration.

Nigga learn how to take a screenshot before you try to code

>"whats wrong with my code"
>takes photo of screen instead of print screen

get out

HAHA

no u

Poop outside. Just go take a quick shit outside your house now. Even if you don't need to go, just pull down your pants, squat and push, let your rectum peek out a little.
After this enlightening experience, your Java code will work.

1. OP cannot into screenshots
2. return ();
Is this the new Jow Forums meme?

I can't believe that you are real

Attached: 1529446927708.jpg (960x731, 122K)

public static String repeatString(String text, int numReps)
{
String combined = text;
if(numReps

>input was null
>didnt handle 0 repititions properly
you failed

if youre trying to get a job just say that you are a gay pro feminism

all this brainlet
text.repeat(numReps); // since java 11

Stop doing this shitters homework.

>input was null

If anyone passes a null into repeatString they deserve an NPE. WTF do you expect. desu it's not worth even checking for but if you must use Objects.requireNonNull or whatever it is
Converting null to empty string was retarded when Oracle did it and it still is

Hey, pretty good attempt! Keep at it!

public String repeatString(String text, int numReps){
if(numReps < 0){
//negative number of repitions doesn't really make sense,
//idealy we'd throw some sort of validation exception
// a la` 'throw new ValidationException("Negative number of repitions")'
// you could use Google's guava precondition here as well, you might not have
// acces to the library though
// You could probably treat negative numbers similar to numReps == 0 case
}
if(numReps == 0){
//Repeat 0 times means to not repeat at all
return "";
}
if(numReps == 1){
//single repition means we return text itself
return text;
}

//In Java it is generally preferable to use StringBuilder class to append or build out
//large strings. It's not really magical, it's just a thing that helps your program
//deal with strings more efficiently
StringBuilder sb = new StringBuilder();
for(int i = 0; i < numReps; i++){
//for numReps = 2 we'd do 2 itterations, for 3 we'd do 3 etc
sb.append(text);
}

//We take the combined Strings in the String builder and return them as a String
// instead of StringBuilder
return sb.toString();

//In Case you do not have access to StringBuilder
// you could also do
// for(int i = 0; i < numReps; i++){
// text += text;
// }
// return text;
}

Good catch! Null checks get the most seasoned devs.

An API like that should ideally handle null checks. The question however is what does his particular environment do once an exception is thrown (like ValidationException) ? My guess is that w.e. education software he is using would simply blow up in a very mysterious ways.

That just adds to the charm

Attached: 3.gif (230x220, 1.81M)

lol gr8 b8

cringe

Attached: 963e00351848ebb5556adf9965fd9873-c.jpg (800x550, 104K)

Please die.

Go take a break mang, you aren't thinking clearly about what it is that you're trying to do.

Seriously, go do something else. Go to bed, wake up tomorrow and try again, but this time, think it through all the way instead of just changing stuff willy-nilly and hoping that it works.

This handles the edge cases so poorly I'm honestly not sure what the requirement in the first place was exactly.

^ this.

The absolute state of zoomers

True. OOP and IL stuff is normie tier programming.

What the fuck is 'return ()'

Only poor carpenters blame their tools.

>WTF IS WRONG WITH MY CODE
>java
well you probably didn't do the needful

The cause of the error

Attached: i know nothing.jpg (434x401, 32K)

last line says: return ();
That's incorrect. It has to return a String. Even an empty one like:
return "";
But it can't be nothing.
Always keep in mind what the returned value of you method should be.

You don't even need that else{}, just delete it and it will work.

Just disable the compiler errors lol.

I like the idea that this would have gone better in a different language.

>not using StringBuilder
public String repeat(final String input, final int n) {
StringBuilder sb = new StringBuilder();
for (int i = 0; i < n; ++i)
sb.append(input);
return sb.toString();
}

it's like you want your code to be shitty

>having a second conditional for the return
Brainlet.png

there's nothing wrong with that

Jezus. Use java code style convention ya fucknut. { goes on same line.

At what point can I say that I know Java on my resume?

>java
this is the problem

When you know differenece betwen final finally and finalize.

>going straight to the last error
Dumbass.
I believe it's complaining about () after return. You probably want "".

>those purple legs
imma need to see that wallpape my dude

This have to be fake

Attached: 1537681057984.gif (382x554, 2.57M)

Return is a keyword not a Funktion you mouthbreather

it could return nothing if its void function like that
void dosomehting(T arg)
{
//do something
if (//terminating condition) return;
else
//rest of code
}

maybe you should learn to sanitize your inputs niglet

"return ();" is never valid in Java though. using parentheses implies that a value should be returned (because parentheses start an expression). but if there isn't any expression inside the parens, that's a syntax error.

>for(int i = 0; i < numReps; i++){
> text += text;
>}
>return text;
You spent all that time annotating and you still couldn't get that right.

I can't even use Python.

I don't know whats worse. Running Windows or trying to get Java done on Windows

haha i did one too. op is so dumb

Attached: Capture.png (802x592, 20K)

>learning java in 2018

Attached: Capture.png (509x133, 6K)