Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
Because IP addresses are in fact numbers, and subnet calculations are made by bitmasking the IP address and the network mask.
Storing them as strings is only helpful for readability, and it's pretty trivial to turn them into strings if you need to print them somewhere.
BTW, wouldn't it be correct to use decimal notation instead of hexadecimal to make it more readable?
Inet4Address.getByAddress(new byte[] {127, 0, 0, 1}) -
I also wrote that shit.
It's the only way that doesn't force you to write a fucking try-catch block because you may have misspelled the address. Or that doesn't desperately try to resolve the string to the nearest DNS server while you just wanted to have a fucking localhost address.
Oh, and because the only-fucktard factory method accepts a byte array, you cannot just put decimal numbers because they would be treated as signed integers, forcing you to add a cast on each number. Hex literals are fine.
That's Java, folks🤷♂️ -
rant1ng44626y
-
@rant1ng redundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundandundan...
java.lang.StackOverflowError -
plttn1596yYeah doing it this way is so much easier. I had to make an assignment that did subnet calculation, and being able to bitwise shift made life so much easier.
Related Rants
-
linuxxx32*client calls in* Me: good morning, how can I help you? Client: my ip is blocked, could you unblock it for m...
-
DRSDavidSoft28Found this in our codebase, apparently one of my co-workers had written this
-
linuxxx23*client calls* "hello, we forgot the password to our WiFi router. Could you reset that for us?" 😐😶😮...
So I found this in the code:
Inet4Address.getByAddress (new byte[] {0x7f,0x00,0x00,0x01})
It's localhost. Why the actual fuck would you declare 127.0.0.1 as a fucking byte array!
rant
ip addresses
coding horror
wtf