+ 1

.write vs .println

whats the different ? sorry but I dont really have the understanding of java programming. I just start few hours ago after my teacher tell me we gonna learn some socket programming this sem.. example : int data; system.out.write(data); // what does this do ?

28th Sep 2018, 4:23 PM
Muhamad Fathi Zuhaili
Muhamad Fathi Zuhaili - avatar
4 Respostas
+ 1
print() formats the output, while write() just prints the characters it is given. print() handles many argument types, converting them into printable strings of characters with String.valueOf(), while write() just handles single characters, arrays of characters, and strings. To illustrate the difference, write(int) interprets the argument as a single character to be printed, while print(int) converts the integer into a character string. write(49) prints a "1", while print(49) prints "49". source: http://www.coderanch.com/t/398792/java/java/write-print
28th Sep 2018, 4:55 PM
Daniel (kabura)
Daniel (kabura) - avatar
+ 7
// println() prints a line of text to the screen.
28th Sep 2018, 4:45 PM
program
program - avatar
+ 4
// After the string, he have the \n, it is used to create the new line, this is for println() in Java
28th Sep 2018, 4:56 PM
program
program - avatar
0
Daniel (kabura) which means write store it .. and print display it . right ?
29th Sep 2018, 9:22 AM
Muhamad Fathi Zuhaili
Muhamad Fathi Zuhaili - avatar