cm0002@lemmy.world to Programmer Humor@programming.dev · 11 个月前Does this exist anywhere outside of C++?lemmy.mlimagemessage-square58linkfedilinkarrow-up1167arrow-down122cross-posted to: programmerhumor@lemmy.ml
arrow-up1145arrow-down1imageDoes this exist anywhere outside of C++?lemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 11 个月前message-square58linkfedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squareschnurritolinkfedilinkarrow-up3·11 个月前Kinda in Java, you can call System.out.println or you can call System.out.print and explicitly write the newline.
minus-squareuranibaba@lemmy.worldlinkfedilinkarrow-up2·11 个月前I 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-squareScoopta@programming.devlinkfedilinkarrow-up2·11 个月前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.
minus-squareuranibaba@lemmy.worldlinkfedilinkarrow-up1·11 个月前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. :-)
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
printlnwas a call toprintwith a new line added to the original input.Something like this:
That is pretty much what it does except it doesn’t hardcode
\nbut 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. :-)