@cm0002@lemmy.world to Programmer Humor@programming.dev • 15 days agoDoes this exist anywhere outside of C++?lemmy.mlimagemessage-square58fedilinkarrow-up1167arrow-down123cross-posted to: programmerhumor@lemmy.ml
arrow-up1144arrow-down1imageDoes this exist anywhere outside of C++?lemmy.ml@cm0002@lemmy.world to Programmer Humor@programming.dev • 15 days agomessage-square58fedilinkcross-posted to: programmerhumor@lemmy.ml
minus-square@schnurrito@discuss.tchncs.delinkfedilink2•15 days agoKinda in Java, you can call System.out.println or you can call System.out.print and explicitly write the newline.
minus-square@uranibaba@lemmy.worldlinkfedilink2•15 days agoI haven’t looked at the code but I always assumed that println was a call to print with a new line added to the original input. Something like this: void print(String text) { ... } void println(String text) { this.print(text + '\n'); }
minus-square@Scoopta@programming.devlinkfedilink2•15 days agoThat is pretty much what it does except it doesn’t hardcode \n but instead uses the proper line ending for the platform it’s running on.
minus-square@uranibaba@lemmy.worldlinkfedilink1•12 days agoI haven’t worked with java for a couple of months now, currently working in Delphi, so could not remember the how else to do new line except backslash n on top of my head. :-)
Kinda in Java, you can call System.out.println or you can call System.out.print and explicitly write the newline.
I haven’t looked at the code but I always assumed that
println
was a call toprint
with a new line added to the original input.Something like this:
void print(String text) { ... } void println(String text) { this.print(text + '\n'); }
That is pretty much what it does except it doesn’t hardcode
\n
but instead uses the proper line ending for the platform it’s running on.I haven’t worked with java for a couple of months now, currently working in Delphi, so could not remember the how else to do new line except backslash n on top of my head. :-)