0

I’m new ish

So, why does this use print in instead of log? If it just needs to go to console why wouldn’t you use console.log (variable/“text”)

6th Aug 2024, 6:18 AM
Parker Ginsberg
Parker Ginsberg - avatar
4 ответов
+ 2
Hi, to clarify, Java and JavaScript are not the same language. And different methods have different purposes. You mentioned 'print in,' but that's actually 'println,' which is short for 'print line.' 'println' is called that because it prints its characters followed by a newline character (\n), which moves the cursor to the start of the next line after printing. If you don't need to move to the next line, you can just use 'print.' 'console.log()' is not a Java method; it's a built-in function in JavaScript used to print messages to the browser's console. Used for troubleshooting with (developer tools). Both Java and JavaScript can print to a console, but the people who created the languages had different ideas. In Java, the goal is to output from the system, write text on a line, and then move to the next line. System.out.println() JavaScript, on the other hand, says, 'That's overthinking! Just log to the console. console.log()
6th Aug 2024, 7:10 AM
Chris Coder
Chris Coder - avatar
+ 1
if device has console Java also can use it as System.console() .printf("%s", "Console ok"); but it is not frequently used
6th Aug 2024, 1:14 PM
zemiak
+ 1
This is a good read for The Console: System.out https://www.oreilly.com/library/view/java-io/1565924851/ch01s06.html#:~:text=The%20console%20is%20the%20default,shell%20window%20(Figure%201.2).
6th Aug 2024, 6:41 PM
Chris Coder
Chris Coder - avatar
7th Oct 2024, 4:43 AM
Youngplaystore
Youngplaystore - avatar