r/programminghumor • • 7d ago

Java

Post image
1.4k Upvotes

27 comments sorted by

130

u/y0shii3 7d ago

How you do it
vs how your teacher does it
vs how your classmate does it
vs how Spring devs do it

8

u/Zealousideal_Joke552 5d ago

Meanwhile C++ madmen that refuse to use a library or framework and make everything from scratch

3

u/generic_human97 3d ago

My physics teacher once gave us a group project to simulate a falling ball’s force and velocity at each millisecond, basic stuff, and my partner wrote the code in C with no libraries using inline assembly. Absolute madman.

1

u/valerielynx 1d ago

why is the teacher bit so real

am i not as smart as i thought i was is this a common thing

76

u/Ignisami 7d ago edited 7d ago

You're missing

if (Boolean.TRUE.equals(condition)) which is what SonarQube's default Java rules will recommend. (edit: in case anyone wonders, it's because of null safety; if (condition) throws an NPE if condition is null, Boolean.TRUE.equals(condition) just evaluates to false)

39

u/NoWeHaveYesBananas 7d ago

What if you want it to throw an error, and not hide your bugs like a coward

23

u/vanteli 7d ago

you tighten your pussy like a man and assert condition != null;

20

u/Ignisami 7d ago
try {
if (condition) { /* code whatever */ }
} catch (MommaAintRaisedNoCowardException _) {
log.error("No bugs to be seen here no sirreee");
}

public class MommaAintRaisedNoCowardException  
 extends NullPointerException   
{ /* standard exception stuff */ }

21

u/yousirnaime 7d ago

if( LlmService.request(" does this seem truthy, respond only 'yes' or 'no' : " . condition) == '{"response":{"message":"yes"}}'){

}

13

u/Simple-Olive895 7d ago

if (myBool == true) {

return true

}

2

u/xaranetic 6d ago
package check.true;

public class TrueCheck {

    public enum Truth {
        TRUE;

        public boolean asPrimitiveBoolean() {
            return Boolean.parseBoolean(this.name().toLowerCase());
        }
    }

    public static class True {
        private final Truth truth;

        private True(Truth truth) {
            this.truth = truth;
        }

        public static True getTrue() {
            return new True(Truth.TRUE);
        }

        public boolean value() {
            return this.truth.asPrimitiveBoolean();
        }
    }

    public boolean checkIfTrue(boolean myBool) {
        if (myBool == true) {
            return True.getTrue().value();
        }
        return !True.getTrue().value();
    }
}

15

u/Varderal 7d ago

Reminds me of one time in a class. I needed to get from one datatype to another with no clear way... I kinda did "variable.toThis.toThat.toAnother.toTarget". Asked rhe teacher if there was an easier way and he just looked at it and went "the fuck is that?" I was all "exactly!" XD

3

u/realmauer01 7d ago

Sometimes that happens in java, you have to transform stuff to a stream that stream to an array and then you can do stuff like for each or map.

6

u/Dinatoc_208 7d ago

when you're paid per line of code

4

u/Forward_Republic_610 7d ago

I am missing the hangman in the last picture.

3

u/AndromedaGalaxy29 6d ago

second one is good for readability sometimes 

3

u/MallAgreeable5538 4d ago edited 4d ago

Istrueclass istrueobject(valuetrue);
if(istrueobject.istrue(boolean)){

2

u/CjMori23 7d ago

This is what the twitter devs that didn’t get fired were writing

1

u/NoodlyGirl2000 7d ago

I do have a lot of fond memories of Java, but I also think C# does it so much better

1

u/induality 7d ago edited 7d ago

The fourth one isn’t even correct. The comparator compare method returns an int. You need to check that that return value equals zero.

1

u/tatstytastycakes 7d ago

class vs homework vs quiz vs exam

1

u/DONARUDO_TURANPU 6d ago

Doesn't Java have some ternary operator like JS? That would be the first image but in full HD 3D

1

u/Zezerok 6d ago

I do most time 1 and sometimes 2 for the readability

1

u/TheSheepDev 4d ago

Java
Jav
Ja
J

1

u/Cat_Player0 22h ago

what is this genre of meme called

0

u/ThePhyseter 7d ago

Guy #3 came from Javascript and never learned about == vs ===